Page 1 of 1

Problem start making leJOS programs

Posted: Wed Jul 11, 2007 10:58 am
by quack
Could anyone explain me how do I start making leJOS programs to my NXT? I don't even know which program to use to write the code and how to transfer it to my NXT (there is no drive related to NXT in My Computer)...

(sorry for my english, i'm portuguese)

Posted: Wed Jul 11, 2007 2:21 pm
by 99jonathan
Hello!! Welcome to the forums!

First, download and install:

If you don't have the lego nxt software installed, do so.

Next, set the environment variable LEJOS_HOME to the full path of the lejos_nxj directory.

Add the lejos_nxj/bin directory to your PATH.

Here is a sample program to test:
Open a command window
Check that java and lejos are on your PATH
Change to the lejos samples\Tune directory
Type lejosjc
Type lejoslink Tune -o Tune.bin
Check that your USB cable is connected
Press the orange button to turn on the NXT
Check that the NXT is in firmware update mode. Put it in it by pressing the reset button for more than 4 secs. The screen should be blank and the NXT should be audibly clicking.
Type lejosdl Tune.bin
A tune should play

When you use lejosdl your program will download and run. You can stop a program by pressing the ENTER and ESCAPE (orange and grey square) buttons together. This powers down the NXT immediately. Press the ENTER (orange) button to wake it up again.

You can also power down the NXT with ENTER + ESCAPE, after an Exception occurs.

You can program in a simple text editor like notepad and save as .java or you could use such editors as Eclipse. If you do use eclipse, the simplest way to set up lejos in it is to rightclick on your project and choose properties. Select "Java Build Path" and then Libraries. Click on the JRE library and press remove. "Add External JAR" and choose the classes.jar in your lejos directory/lib. That will get you started up!!

If you want some preliminary help with Java programming or beginning lejos, you can read this:

Posted: Wed Jul 11, 2007 2:41 pm
by quack
Thanks a lot.

Posted: Wed Jul 11, 2007 3:31 pm
by quack
I have another question.

You talked about using eclipse. Is there a way (plugin maybe) that allow to compile and test with an emulator and then send it to the NXT?

Or I still have to do it with command line?

Posted: Wed Jul 11, 2007 5:00 pm
by boozer
check out for easy debug/compile/link/project management tools. No emulator that I know of though..

Posted: Wed Jul 11, 2007 5:08 pm
by 99jonathan
The only current emulator is for Linux... :cry:

Posted: Wed Jul 11, 2007 5:41 pm
by quack
so it's the same... i'll have to build the .bin file and send it to NXT always through command line no matter which text editor i use.. right?

Posted: Wed Jul 11, 2007 6:59 pm
by boozer
If you use eclipse: you can create an external program tool that runs the command lines in the console automatically at the press of a button or assignable quick-key.

The eclipse IDE integrates an editor, console, debugger, builder, package viewer, cvs, and project file management tools all on one interface. I highly recommend it.

Posted: Thu Jul 12, 2007 2:15 am
by 99jonathan
Any instructions on how to set up such an external program?

Posted: Thu Jul 12, 2007 1:58 pm
by quack
I would like those too..