leJOS NXJ FAQ

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: imaqine, 99jonathan, roger

imaqine
Moderator
Posts: 80
Joined: Sun Apr 08, 2007 6:20 am
Contact:

leJOS NXJ FAQ

Postby imaqine » Thu Jun 21, 2007 1:57 pm

What is leJOS NXJ?
leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2006 it was ported to the LEGO NXT brick.

leJOS NXJ includes all the classes in the NXJ API as well as the tools used to upload code to the NXT brick.

leJOS NXJ offers the following:

Object oriented language (Java)
Preemptive threads (tasks)
Arrays, including multi-dimensional
Recursion
Synchronization
Exceptions
Java types including float, long, and String
Most of the java.lang, java.util and java.io classes
A Well-documented Robotics API
A PC based API that allows you to talk to the NXT.

What is the current release of leJOS NXJ?
leJOS NXJ 0.85

Where can I download the current release?
http://sourceforge.net/projects/lejos/files/

How can I learn NXJ leJOS?
Probably the best place to start is the tutorial:
http://lejos.sourceforge.net/nxt/nxj/tutorial/index.htm

If you are good with Java you can study the API:
http://lejos.sourceforge.net/nxt/nxj/api/index.html

You can check out the examples folder that is included with leJOS. Or you can purchase a book (see below)

Is there a book that I can buy that goes into further detail of leJOS NXJ?
Maximum LEGO NXT

I can’t get XXX to work properly, I need help! What do I do?
First, take a look at the readme.html that came with leJOS. Make sure you completely look over it. If you do not understand a portion or have questions, search the leJOS forum for your answer. If, and ONLY if, you cannot find your answer by searching then post your question on the leJOS forum.

What is the current priority list for the NXJ firmware?
http://lejos.sourceforge.net/forum/viewtopic.php?t=225

How to use buttons with the menu system?
The orange (ENTER) button activates the current selection, sometimes opening a sub-menu.
The gray (ESCAPE) button returns to the higher menu level.
The arrow buttons move the selection indicator.
Press ENTER + ESCAPE together to end the program and turn off the NXT.


How do I decipher the exception codes?
The Class part of the exception code tells you the numeric id of the exception that has been thrown. The best way to turn this into an actual class name is to link your program with the -v option and use the output. Some of the exception codes (those used by the VM) do not change from program to program, and these are shown below. For others you need to check the linker output.

The method part of the exception tells you which method number the exception was thrown in. Again you can use the the linker output to lookup the name of the method. The following thread provides a little more detail:
http://lejos.sourceforge.net/forum/viewtopic.php?t=1215&highlight=exception

The fixed exception numbers (for 0.85) are:

Class 1: java.lang.Throwable
Class 2: java.lang.Error
Class 3: java.lang.OutOfMemoryError
Class 14: java.lang.NoSuchMethodError
Class 15: java.lang.StackOverflowError
Class 16: java.lang.NullPointerException
Class 26: java.lang.ClassCastException
Class 27: java.lang.ArithmeticException
Class 28: java.lang.ArrayIndexOutOfBoundsException
Class 29: java.lang.IllegalArgumentException
Class 30: java.lang.InterruptedException
Class 31: java.lang.IllegalStateException
Class 32: java.lang.IllegalMonitorStateException
Class 33: java.lang.ThreadDeath
Class 34: java.lang.ArrayStoreException
Class 35: java.lang.NegativeArraySizeException

I'm running 0.8.5 and my Ultrsonic sensor and/or my Lego Color sensor does not work, what can I do?
There is an updated classes.jar that fixes these very common problems. See the following thread for details
http://lejos.sourceforge.net/forum/viewtopic.php?f=7&t=1883

Where can I find a tutorial on NXJ installation and Eclupse?
http://lejos.sourceforge.net/nxt/nxj/tutorial/Preliminaries/UsingEclipse.htm

Where can I find a tutorial on NXJ installation and Netbeans?
http://lejos.sourceforge.net/nxt/nxj/tutorial/Preliminaries/UsingNetbeans.htm

This FAQ is still in development. If you have any additional questions that you feel should be on this FAQ please post below. Thanks![/url]

bdferris
New User
Posts: 3
Joined: Fri Oct 26, 2007 11:55 pm

CVS Access for lejos-NXJ?

Postby bdferris » Fri Oct 26, 2007 11:58 pm

Is there CVS access available for the lejos-NXJ source tree? The CVS trees listed on the sourceforge project page seem to refer only to the RCX tree.

User avatar
bbagnall
Site Admin
Posts: 392
Joined: Fri Aug 04, 2006 4:03 pm

Re: CVS Access for lejos-NXJ?

Postby bbagnall » Sat Oct 27, 2007 6:01 pm

bdferris wrote:Is there CVS access available for the lejos-NXJ source tree? The CVS trees listed on the sourceforge project page seem to refer only to the RCX tree.

You have to go into Subversion (SVN) to see the leJOS NXJ code.

reformy
New User
Posts: 7
Joined: Mon Jan 28, 2008 3:34 pm

go back to NXT original firmware, and memory questions

Postby reformy » Mon Jan 28, 2008 7:12 pm

hi
i have two questions:
1. can i easily go back to the original NXT firmware after installing leJOS on my NXT brick?
2. how much memory is available for java programs under leJOS? is that enough for bigger-than-common applications?

thanks,
yair

lawrie
leJOS Team Member
Posts: 965
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Sat Feb 02, 2008 7:54 pm

To go back to the Lego firmware, you do a long reset of the NXT to go back to firmware update mode, and then do Update NXT Firmware from the Tools menu in the Lego Mindstorms NXT software. You can swap between them in a minute or two.

You get about 50kb of RAM for the data of your Java program, and the program runs from flash memory and can be up to about 150kb, although there are some limits you might hit before a program gets to that size.

agsgymboy
New User
Posts: 3
Joined: Tue May 20, 2008 9:55 pm

Postby agsgymboy » Tue May 20, 2008 9:58 pm

Can leJOS run origional programs made with the NXT software the NXT comes with? What about the RCX software?

lawrie
leJOS Team Member
Posts: 965
Joined: Mon Feb 05, 2007 1:27 pm

Postby lawrie » Tue May 20, 2008 11:08 pm

No, leJOS cannot run NXT-G programs. leJOS RCX programs cannot run on the NXT but are fairly easy to convert.

drummerp
New User
Posts: 22
Joined: Mon Jun 15, 2009 10:07 pm

Postby drummerp » Mon Jun 15, 2009 10:24 pm

What do you do if, when trying to compile code, you get the error message, "javac is not recognized as an internal or external command, operable program, or batch file." in the Eclipse IDE?

User avatar
Shawn
Advanced Member
Posts: 723
Joined: Wed Sep 12, 2007 4:59 am
Location: Tokyo

Postby Shawn » Tue Jun 16, 2009 9:32 am

drummerp wrote:What do you do if, when trying to compile code, you get the error message, "javac is not recognized as an internal or external command, operable program, or batch file." in the Eclipse IDE?


Have you looked at http://lejos.sourceforge.net/nxt/nxj/tutorial/Preliminaries/UsingEclipse.htm

drummerp
New User
Posts: 22
Joined: Mon Jun 15, 2009 10:07 pm

Postby drummerp » Tue Jun 16, 2009 3:03 pm

Uhhh, no. :P

westes
New User
Posts: 21
Joined: Wed Jul 22, 2009 12:38 am

Postby westes » Fri Jul 24, 2009 6:08 pm

You need to setup the java bin directory in your System Variables

jhebus
New User
Posts: 6
Joined: Wed Sep 18, 2013 8:56 pm

Re: leJOS NXJ FAQ

Postby jhebus » Wed Sep 18, 2013 9:02 pm

Hi there,

I am curious about the ability to update the flash of the device.

I would like to be able to modify the section of flash that contains the program code at runtime- i.e. add more classes. From what i have read it would seem that this is not possible. Do i have this wrong?

Secondly, if i were to copy my own definition of a class at runtime into the file system as a file, and if i wrote my own VM to interpret this, would this be possible? I don't understand enough about the make up of the system to see how this would or would not work. AS far as i can see this would be me creating a small VM ontop of the JVM. We can ignore performance for the moment.

Thanks in advance.

User avatar
gloomyandy
leJOS Team Member
Posts: 5995
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: leJOS NXJ FAQ

Postby gloomyandy » Wed Sep 18, 2013 9:56 pm

Well you can certainly write to a file at run time and since leJOS programs are files that is not a problem. However there is no way to get leJOS to run the newly written code unless that code is a complete program and you then run that program (which is certainy possible and is in effect what happens when you download and run a program).

As to writing your own VM yes you can do that, and you would then be able to read "byte code" from a file, so I don't see why this would not work. Note however that the leJOS file system is very limited, so trying to delete files and create new ones can easily cause problems.


Return to “NXJ Software”

Who is online

Users browsing this forum: No registered users and 5 guests