What Is NXJ and How Does It Run Java on LEGO Mindstorms NXT?
NXJ is the leJOS replacement firmware that lets a LEGO Mindstorms NXT brick run Java programs. You use it when your target hardware is the NXT (not the older RCX or the newer EV3), and you want to write robot code in Java instead of the stock NXT-G visual language. The leJOS project describes itself as "a Java based replacement firmware for the Lego Mindstorms RCX microcontroller," with NXJ being "a Java based replacement firmware for the Lego Mindstorms NXT microcontroller" — so NXJ is the NXT-specific branch of the same project.
Where NXJ fits in the leJOS family
The leJOS site splits its work by brick generation. Picking the wrong branch is the most common early mistake, because the firmware, API, and PC-side tooling differ per brick.
| Branch | Target brick | What it is |
|---|---|---|
| leJOS NXJ | LEGO Mindstorms NXT | Java replacement firmware for the NXT microcontroller |
| leJOS RCX | LEGO Mindstorms RCX | Java replacement firmware for the RCX microcontroller |
| leJOS EV3 | LEGO Mindstorms EV3 | Separate Java firmware line, released later (0.9.1-beta as of Nov 16, 2015) |
If you own an NXT, NXJ is the branch you want. If you own an EV3, the site's news entries point you to the EV3 releases and their Wiki instructions instead.
How Java actually runs on the NXT
The NXT brick does not run a desktop Java Virtual Machine. NXJ relies on a small Java runtime — the project's keyword list names TinyVM, the compact VM lineage behind leJOS — that fits the brick's limited memory and processor. Your Java source is compiled on the PC, then the resulting class files are linked and uploaded to the brick, where the on-brick runtime executes them.
Two practical consequences follow from that design:
- You develop on a PC, run on the brick. Compilation and linking happen on the host; only the finished program goes to the NXT.
- The PC side needs its own API. leJOS provides a PC API and an ICommand layer so host software can talk to the brick — for uploading programs and for communicating with a running robot.
The basic workflow
The exact menu names and commands live in the leJOS NXJ tutorials and Wiki, which the site links from its NXJ section. At the level the project documents, the sequence is:
- Install the NXJ firmware on the NXT brick, replacing the stock firmware.
- Set up the PC toolchain — the leJOS NXJ downloads include the API and the host-side tools you compile and upload with.
- Connect the brick to the PC using the PC API / ICommand communication path.
- Write and compile your Java program against the leJOS NXJ API.
- Link and upload the program to the brick, then run it there.
Verify each stage before moving on: after step 1 the brick should boot into leJOS rather than the stock firmware; after step 5 the program should start on the brick without the PC attached.
Common sticking points
- Wrong branch. Installing EV3 or RCX tooling against an NXT will not work; confirm you are in the NXJ downloads and tutorials.
- Version drift on the host side. The EV3 release notes show the project's habit of requiring you to update the Eclipse plugin alongside the firmware. Expect the same discipline on the NXT side: keep the PC API and the brick firmware from the same release.
- Assuming a full JVM. Because the on-brick runtime is a compact VM, not every desktop Java library is available. Check the NXJ API for what the brick actually supports.
Where to start
The leJOS site organizes NXJ as three entry points: API, PC API, and Tutorial, plus a Downloads page. Begin with the tutorial and downloads for your release, keep the API reference open while coding, and use the PC API when you need host-to-brick communication. The FAQ and forum are linked from the same navigation if you hit a problem the tutorial does not cover.