Getting Started with leJOS NXJ


First of all you should go to NXJ downloads to find the version of leJOS you want to use.

When downloaded and unpacked you are ready to install leJOS on your computer and the NXT controlunit. To install and run your first Java program on the NXT read the README file contained in the leJOS download. This is the complete description of what to do.

In the leJOS Tutorial there is a more readable description of the installation process:

  • In Getting started select the operating system to be used. At first use the USB cable, wait with the Bluetooth connection.

  • Follow the installation process and run the "Hello World" program as described in Writing and Running your first leJOS NXJ program.

  • In PC GUI Tools the The NXJ Browser is described. To run the NXJ Browser try the command nxjbrowse from a command window and use nxjbrowse to see what is in the file system of the NXT after "Hello World" have been executed.

  • Compiling and Running Programs describes how the leJOS command line tools can be used to compile, link and run leJOS programs both on the computer and on the NXT. The Tutorial, however, also include an installation guide for e.g. a leJOS plug-in for Eclipse. Install this plug-in. Try to make the "Hello World" program run on the NXT from Eclipse.

  • Under the headline "Importing the samples and examples into Eclipse" in leJOS plug-in for Eclipse it is described how to import leJOS sample programs. Try the program USBReceive.java from the sample folder. When the NXT is in the state waiting for a connection over the USB cable, run the program USBSend.java from the folder pcsample on the computer to see that the USB cable can be used directly to communicate messages between the computer and a leJOS program running on the NXT.

  • Now we will try the Bluetooth connection to the NXT. Use the Bluetooth menu in the The leJOS NXJ Menu System to turn on Bluetooth on the NXT. Pair the computer with the NXT. Try to connect to the NXT with the command nxjbrowse and Bluetooth.

  • Try the program BTReceive.java from the sample folder. When the NXT is in the state waiting for a connection over Bluetooth, run the program BTSend.java from the folder pcsample on the computer to see that Bluetooth can be used directly to communicate messages between the computer and a leJOS program running on the NXT.

  • In the LEGO Mindstorms Education NXT Base Set 9797 there is a building instruction for a car, page 8 to page 22. Build this car.

    Figure 1 The 9797 LEGO car with two motors.

    The program RemoteController.java in RemoteControl.zip is a leJOS PC program that can be used to remote control the 9797 LEGO car: Turn on the NXT and run RemoteController.java on the computer. The car make a beep sound when it is ready to be controlled from the computer by means of the arrow keys and the slider in the GUI. The connection is via Bluetooth.


Last update: 21-01-15