LejosInstallInstructions.docx
- 文档编号:9536588
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:10
- 大小:357.97KB
LejosInstallInstructions.docx
《LejosInstallInstructions.docx》由会员分享,可在线阅读,更多相关《LejosInstallInstructions.docx(10页珍藏版)》请在冰豆网上搜索。
LejosInstallInstructions
InstallingNXJ
Firstthingsfirst!
MakesureyouhaveinstalledtheJavaSoftwareDevelopmentKit(SDK)fromSunMicrosystems,preferably1.5orlater.
MakesureyoursystemhasJAVA_HOMEsettotherootdirectoryoftheJDK(seestep5below).TheSuninstallershoulddothisautomatically.
YourPATHmustcontaintheSDK'sbindirectory(seestep6belowforsettingPATH).Again,theSuninstallershoulddothisautomatically.
Nowlet’sinstallleJOSNXJ.Choosetheappropriateinstructionsforyoursystembelow.
Note:
TheleJOSdownloadcontainsthelatestsetupinstructions.Ifyouexperienceanydifficultusingthestepsbelow,refertotheinstructionsassomeproceduresmighthavechanged.
Windows
MakesureyouhaveinstalledtheLEGOMindstormsNXTsoftware.TheWindowsversionofleJOSNXJusesthesefilestouploadcodeviaUSB.
1.YourfirststeponthepathtoleJOSblissistodownloadthelatestversionfromwww.lejos.org.
2.Unzipthecontentsintoadirectory.e.g.c:
\java\lejos_nxj
3.Nowweneedtosetsomeenvironmentvariables.SelectStart>ControlPanel>System.ClicktheAdvancedtab,thenEnvironmentVariables(Figure2-1).
Figure2-1Viewingtheenvironmentvariables
4.ClickNewtocreateanewenvironmentvariable.ItcaneitherbeinSystemvariables(ifmultipleuserswilluseleJOS)orUservariablesifyouraccountistheonlyoneusingleJOS.TypeNXJ_HOMEasthevariablenameandaddtheleJOSdirectory(seeFigure2-2).ClickOK.
Figure2-2SettingtheleJOShomedirectory.
5.Whileyouareintheenvironmentvariables,checktomakesureJAVA_HOMEhasbeensetup.Ifnot,addthisvariableandtypeinthedirectorytoyourJavaSDK.
6.Finally,addthebindirectorytoyourpathsoyoucanusetheleJOScompilertoolsfromthecommandline.Addthefollowingtotheendofyourpathvariable(seeFigure2-3).
;%NXJ_HOME%\bin
Figure2-3SettingthepathtotheleJOSbinaries.
7.NowdownloadandinstalltheUSBdriversfromthefollowingwebsite:
http:
//libusb-
Downloadtheexecutablefilethathasbininthename.Whenyourunthisfileitwillinstalltheproperfiles.
That’sall!
YoucannowskipdowntoUploadingFirmware.
Linux
1.Downloadanddecompressthetarfilefromwww.lejos.org.
2.AddtheenvironmentvariableNXJ_HOMEandsetittothedirectoryyouinstalledleJOS.
3.AddtheleJOSbindirectorytoyourPATH.Dependingontheprivilegesettings,youmightneedtoadjusttheexecutionpermissionsinthebinfolder.
4.YourPATHmustalsocontaintheantbinary(ant1.6orabove).
5.YouneedlibusbinstalledsotheleJOStoolscanaccessyourUSBport.Thiscanbedownloadedfrom:
6.Nowyouneedtobuildthedistribution.Switchtothebuildfolderandrunant.Notethatdependingontheprivilegesettingsyoumightneedtoadjusttheexecutionpermissionsinthereleasefolder.
That’sall.YoucannowskipdowntoUploadingFirmware.
MacOSX
Macintoshownerscandownloadbinaryfilescompiledjustfortheirsystem.Thesefilesareauniversalbuild,meaningtheywillworkonbothPowerPCandIntelbasedMacOSXcomputers.
TheleJOStoolsforcompilinganduploadingJavacoderuninashellenvironment,suchastcsh.Beforeyoucandothat,youwillneedtosetupsomeenvironmentvariablesforthetcshshell.
1.DownloadtheMacOSXdistributionfromwww.lejos.org.
2.Extractthisfileintoanewlocation,suchas/Applications/lejos_nxj.
3.Ifyouusetheadministratorlogin,youwillneedtocreate(oredit)thefile.tcshrcinyouruserhomedirectory.RuntexteditfromyourApplicationsfolder.
4.Typethefollowingtwolinesintothewindow(usingthedirectorywhereyouextractedleJOS),thensave:
setenvNXJ_HOME/Applications/lejos_nxj
setenvPATH${PATH}:
${LEJOS_HOME}/bin
5.Selectyouradministratordirectory(/users/administrator),andtype.tcshrcasthefilename.Unchecktheboxsaying“Ifnoextensionisprovided,use'.txt'”beforeyousave.Thenyou'llgetawarningboxsuggestingthesenamesarereservedforthesystem(seeFigure2-4).ClickUse'.'anditwillsave.
Note:
Ifyouprefertousecshinsteadoftcsh,youshouldinsteadedit/createthefile.cshrcwiththesamelines.
6.BringupaTerminalwindowandtypetcsh.You'llnowbeinatcshshell.
7.TypesetenvtomakesureyourPATHandLEJOS_HOMEvariablesaresetupcorrectly.That’sall!
YouarereadytotestleJOS.
Figure2-4SavingtheenvironmentvariablesinMaxOSX.
UploadingtheFirmware
ItismucheasierandfastertouploadfirmwaretotheNXTthanitwaswiththeRCXbrick.
1.FirstweneedtoplacetheNXTbrickinfirmwareuploadmode.TheresetbuttoniscleverlyhiddeninaLEGOpinholesoyoudon’taccidentallypressit.TurnontheNXT.Usingabentpaperclip,insertitintotheholeintheupper-rightcorneroftheundersideoftheNXTbrick(seeFigure2-5).Holdthebuttonforatleastfoursecondstoerasethecurrentfirmwareandputitintofirmwareuploadmode.
Figure2-5Usingapapercliptoactivatefirmwareuploadmode.
2.YourNXTbrickshouldbemakingasoftpulsingsound.Nowweneedtouploadthefirmware.PluginyourUSBcableandtype:
nxjflash
3.AfteraverybriefmomentyouwillseetheleJOSNXJlogoandamenusystemwillappear.YourNXTbrickisnowreadytoacceptJavacode.
Warning:
ThereisatheoreticallimittothenumberoftimesyoucanreplacethefirmwareonyourNXTbeforeitwearsout.Everytimeyoureplacethefirmware,apieceofdatacalledalockbitisusedup.Thisbitisratedtowork100times(minimum)beforeitexpires.However,don’tletthisdissuadeyoufromreplacingthefirmwarewithsomethingyouwantmore.Mostengineersagreethatthelockbitwilllastfarinexcessof100times.Chancesareyouwillneverevennoticethislimitationandyouprobablywon’treplaceyourfirmwareenoughtoapproacheven100.
CompilingandUploadingJavaCode
Inthissectionyoucantrycompilinganduploadingsomesamplecodefromthecommandline.WindowsuserscanenterthecommandlinebyselectingStart>Runandthentypingcmd(ClickOK).
1.Fromacommandlineprompt,changetothesamples\tunedirectorywhereyouinstalledleJOS.
cd\java\lejos_nxj\samples\tune
2.YoucanoptionallyopenthefileTune.javawithatexteditortoviewsomeleJOScode.CompilethesampleJavafile:
nxjcTune.java
4.ThiscreatesafilecalledTune.nxj.Nowitistimetouploadthisfile.PluginyourUSBcable(ifyouownaBluetoothdongleyoudon’thavetoplugthisin).TurnontheNXTbypressingtheorangebuttonandtype:
nxj–rTune
AfteramomentyoushouldhearatuneplayfromyourNXTbrick.The–rargumentrunstheprogramautomatically.Ifyouleaveoutthisargument,itwillappearinthemenusystem,whereyoucanrunitmanually.
InstallingaDevelopmentEnvironment
Aswehaveseen,Javaprogrammingispossiblewithatexteditorandacommandline.However,it’seasiertoclickonbuttonstomakethingshappenratherthantypingcommandsandoptionalparameters.Also,mosttexteditorsdon’thavemanyfeaturestohelpyouentercode.Itwon’ttellyouwhenyou’vemisspelledthenameofaclassorforgottenabracket.
AnIDE,orIntegratedDevelopmentEnvironment,isatoolthatallowsyoutoenter,compile,anduploadcodetoyourNXTusingsimplebuttons.Italsomonitorscodesyntax,coloringyourcodesoyoucanmoreeasilyidentifytheparts.Thissectionwillsuggestafree,opensourceIDEforyourleJOSNXJneeds.
OneofthebestopensourceIDEsisEclipsebyIBM(seeFigure2-6).It’sfree,powerful,andeasytouse.ItmakessensetouseamoreadvancedIDEwiththeNXTsinceyourcodecangrowquitelarge.
Figure2-6ProgramminginEclipse.
SettingUpEclipse
1.DownloadEclipsefrom:
www.eclipse.org
2.Decompressthefilesintoadirectory.ThiswillbethepermanentlocationforEclipse.
3.That’sit.Eclipseusesnosetupanddoesn’tstoreregistrysettingsorcopynativelibraryclassestootherdirectories.TorunEclipse,doubleclicktheexecutablefileintheEclipsedirectory(orcreateashortcuttothis).TouninstallEclipse,merelydeletetheEclipsedirectoryfromyourcomputer.
WhenyoufirstrunEclipseyoucanbrowsesomeoptionalhelpfilesandtutorials.IfyouwanttogetrighttoEclipseprogramming,closetheWelcometab.
UsingEclipsewithleJOSNXJ
NowthatyouhaveEclipseinstalledit’stimetoconfigureitforleJOSNXJ.
1.SetupaprojectinEclipseforyourleJOSNXJcode.ClickonFile>New>ProjectandyouwillseethenewprojectWizard(seeFigure2-7).SelectJavaProjectandclicknext.
Figure2-7CreatinganewprojectinEclipse.
2.ForprojectnameentersomethinglikeleJOSNXJ.ClickNextandthenFinished.EclipsecreatesanewfolderforyourleJOSNXJcode.
3.NowweneedtosettheEclipseclasspathtotheleJOSclasses.IntheEclipsemenusselectProject>PropertiesandyouwillseeaPropertieswindowforyourproject.SelecttheLibrariestabandselectJavaBuildPathinthelefthandframe(seeFigure2-8).
Figure2-8Changingprojectproperties.
4.ClickonAddExternalJARs…andbrowsetotheclasses.jarfileinthelibdirectorywhereyouinstalledleJOS.ClickOK.
5.NowweneedtosetuptheleJOStoolstocompileanduploadcodetoyourNXTbrick.SelectRun>ExternalTools>ExternalTools…tobringupanewwindow.SelecttheProgramitemandclicktheNewbutton(seeFigure2-9).
Figure2-9AddingleJOStoolstoEclipse.
6.Firstwe’llcreatethecompilertool(seeFigure2-10).TypeinNXJCompile.Forlocation,clickBrowseFileSystemandbrowsetothe\bin\nxjc.bat.ForWorkingDirectoryclickBrowseWorkspaceandchooseyourleJOSNXJproject.Undera
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- LejosInstallInstructions
![提示](https://static.bdocx.com/images/bang_tan.gif)