This page guides you through the steps to install LeJOS NXJ on the NXT and get you set up to program using a text editor.
1. What do you need?
- Computer
- Lego NXT Brick
- USB-A to USB-B cable
2. Flashing LeJOS NXJ to your NXT
Let’s begin by downloading Java SE 7 Development Kit:
Here is a link to our Java SE 7 download and setup tutorial.
Next we must download the Official LEGO Mindstorms NXT Software:
You will need to install the software and connect your NXT to your computer.
Next we will install the LeJOS NXJ setup software. First, download it here. The page will look like this, click the green Download button shown in this screenshot:

When you click download, a countdown will begin and after five seconds your download will begin. This download should be quick. Once the download is done, the file will appear in your downloads folder, double click it:

Again, you must click Yes to the pop-up asking if you wish this file to make changes to your computer. You will then see a window that looks like this:

After clicking Next, you should see this, a folder selection screen with the jdk1.7.0_80 file selected. If you do not see that the jdk file is selected automatically, you may have accidentally installed the x64 version of the Java SE 7 file. Please uninstall Java and install the correct x86 version. Once you do, repeat the installation process and the jdk file should show up as it does in the picture to the left.

Now, keep clicking Next until you see this screen, and click Install:

Once the installation process is complete, make sure the “Launch NXT Flash utility” box is checked, and make sure your NXT is on and connected, then click Finish.

This window will open up. Click Flash leJOS firmware and follow the instructions on your screen. The flashing process should be quick and you will be notified when it is complete. Do not unplug your NXT until it boots up into the Lejos NXJ menu.


3. How to code the NXT?
This guide will show you how to program the NXT using a Java IDE, or text editor, and the terminal. Start by creating a folder for your coding files inside of your documents folder.

You can then create a project in your text editor of choice. I will be using Sublime Text due to its simplicity and support for Java, but you can use any text editor.
Name your file HelloWorld.java and save it in the folder that you created. Let’s copy and paste this sample code for a simple hello world program:
import lejos.nxt.Button;
public class HelloWorld {
public static void main (String[] args) {
System.out.println("Hello World");
Button.waitForAnyPress();
}
}
Save your file again using “ctrl + S” and open your terminal or command prompt:

Make sure your NXT is turned on and plugged in with the LeJOS NXJ main menu opened. Then, type these commands into the terminal one by one:
> cd documents
> cd <Name of your folder>
> nxjc HelloWorld.java
> nxj -r -o HelloWorld.nxj HelloWorld
The code should run on your NXT Brick and you should see the words Hello World printed on the display. To exit the program, press any button.
This is the documentation for LeJOS NXJ. Here you can find all syntax and functions you will need to code your robot.