The leJOS NXJ Tutorial. Simplified Chinese. The leJOS NXJ Tutorial is a practical guide on how to program the LEGO MINDSTORMS NXT ï¿½ in Java using. The tutorial will teach you how to write Java programs that control a variety of leJOS NXJ is a Java programming environment for the LEGO MINDSTORMS. The leJOS Tutorial. A practical guide for developers with examples and trails– groups of lessons on a particular subject.
|Published (Last):||8 December 2005|
|PDF File Size:||17.23 Mb|
|ePub File Size:||8.9 Mb|
|Price:||Free* [*Free Regsitration Required]|
We will create a HelloWorld class in the default java package:.
We either need the program to sleep for a while to allow the text to be read, or to wait for a button to be pressed. Let us wait for a button to be pressed.
Button is in the lejos. You can find out what methods a class supports by looking at the API documentation.
Writing and Running your first leJOS NXJ Program
Create a file called HelloWorld. Then open a command prompt and execute the following command in the directory in which you created HelloWorld. This will the file called HelloWorld.
This is done with the following command:. This will load the class HelloWorld from HelloWorld.
The classes are then merged together into a single file, namely HelloWorld. However, before that file can be executed, it needs to be uploaded to the NXT brick. Using the commands above, you obtain the Lrjos. You can now upload it to the NXT brick to execute it.
To do that, use the following command:. The parameter -r means, that tutoiral program will be executed after it has been uploaded to the NXT.
By omitting the parameter, llejos will just upload the file and it will not executed automatically. You can then execute HelloWorld. Also, there is the possibility of the linking a program and uploading the result with one single command.
The following command has the same effect as the nxjlink and nxjupload commands above:.
Tutorial on how to install and run Java on Lego Mindstorms NXT using Eclipse
The command first creates HelloWorld. The program is automatically started, since the -r parameter has been specified.
We will create a HelloWorld class in the default java package: The complete HelloWorld program is: This ljos done with the following command: Back to top Uploading and running the program Using the commands above, you obtain the HelloWorld.
To do that, use the following command: The following command has the same effect as the nxjlink and nxjupload commands above: