Problems Using Enum

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

Moderators: roger, 99jonathan, imaqine

Problems Using Enum

Postby Phoen » Sat Feb 09, 2013 9:12 pm

Hi,

I have a problem using Enums with lejos. I also found an post with a similar question, but unfortunately it did not help.

I'm using Eclipse and I want to use Enums in my program but when I try to perform the lejos download it sais:

Code: Select all
Error: Class java.lang.Enum (file java/lang/Enum.class) not found in CLASSPATH .;C:\ProgramFiles\lejos_nxj\3rdparty\lib\bcel-5.1.jar;C:\ProgramFiles\lejos_nxj\3rdparty\lib\commons-cli-1.0.jar;C:\ProgramFiles\lejos_nxj\lib\pctools.jar;C:\ProgramFiles\lejos_nxj\lib\pccomm.jar;C:\ProgramFiles\lejos_nxj\lib\jtools.jar;C:\ProgramFiles\lejos_nxj\3rdparty\lib\bluecove.jar;C:\ProgramFiles\lejos_nxj\lib\classes.jar


When I delete the Enum part in my code everythin works fine again.
I reconstrukted the programme with this simple example:

Code: Select all
public class Main {

   public static void main(String[] args) {
      int speed = 10;
      MyMotor motor1 = new MyMotor (speed, Orientation.LEFT);

   }

}

public class MyMotor {
   
   int speed;
   Orientation orientation;
   
   public MyMotor(int speed, Orientation orientation){
      this.speed = speed;
      this.orientation = orientation;
   }
}

public enum Orientation {
   LEFT, RIGHT;
}


When I switch on my NXT it shows on the display "25124 leJOS 7.4"

Sometimes it changes to "leJOS 7.5" on the display but just for one sec which ist really strange.

Thanks in advance

Phoen
Phoen
New User
 
Posts: 10
Joined: Sat Feb 02, 2013 11:07 am

Re: Problems Using Enum

Postby gloomyandy » Sat Feb 09, 2013 9:25 pm

What version of leJOS are you using? That menu display looks like it is a very old version of leJOS...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3003
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Problems Using Enum

Postby skoehler » Sat Feb 09, 2013 9:45 pm

Phoen wrote:
Code: Select all
Error: Class java.lang.Enum (file java/lang/Enum.class) not found in CLASSPATH .;C:\ProgramFiles\lejos_nxj\3rdparty\lib\bcel-5.1.jar;C:\ProgramFiles\lejos_nxj\3rdparty\lib\commons-cli-1.0.jar;C:\ProgramFiles\lejos_nxj\lib\pctools.jar;C:\ProgramFiles\lejos_nxj\lib\pccomm.jar;C:\ProgramFiles\lejos_nxj\lib\jtools.jar;C:\ProgramFiles\lejos_nxj\3rdparty\lib\bluecove.jar;C:\ProgramFiles\lejos_nxj\lib\classes.jar


First of all, that classpath is completely messed up. It contains libraries that are for PC-side virtual machines (like bluecove.jar, jtools.jar, etc.) and the runtime of the virtual machine on the NXT. Don't do that! In fact, NEVER do that! Remove all libraries from the classpath, except classes.jar, if the program is supposed to run on the NXT. In fact, the bootclasspath has to contain classes.jar if you're compiling/linking programs that run on the NXT. What are you using to compile/link the program?

Furthermore, from the looks of it, you're using an old leJOS version that does not support Enums yet. Upgrade to the latest leJOS version, which has support for Enums.
skoehler
leJOS Team Member
 
Posts: 1104
Joined: Thu Oct 30, 2008 4:54 pm

Re: Problems Using Enum

Postby Phoen » Sat Feb 09, 2013 10:40 pm

Hello skoehler and gloomyandy,

When I start my NXT I see the lejos logo for a couple of seconds and then it goes to the main screen.

Code: Select all
25676   leJOS 7.4
>Files
 Bluetooth
 System


Does this mean the software on my NXT is also very old? I worked through a tutorial from the internet in order to set everything running. When the NXT software is to old, do have to update it too? The problem is, that I don't have a LEGO CD, where I'm not sure if that software is actually on it. Is there a page where I can find a modern NTX System in the internet? On sourcefourge maybee?

Now to the Eclipse part of my question.
I shortly explain what I did every time I created a new project.

In the projects properties I added an external jar (right click on project -> properties -> Java Build Path -> Libaries -> Add Externel JARs...)
Then I selected the classes.jar file in the lib folder where I installed leJOS.

I always thought this was the classpath. Hoever, when I delete this I can no longer use all the nxt commands like
Code: Select all
LCD.drawString("Leg ma los!", 2, 2);


So where or how do I set the bootclass path now?
When I link the download the program on the nxt I have a button in Eclipse. Its to the left of the normal green run button. It has the same little grenn play-sing on it, just like the run button, but it also has a little red suitcase beside it. Is says "Run leJos download". When I cklick on it it links to the NXT, transfers the code on it and then the program starts immediately. By the time the program ended, the NXT switches off automatically.

Is that the right way to do? As a said, I got all this from an tutorial which seems to be very old as i discoverd.

Thanks for your answers,

regards
Phoen
Phoen
New User
 
Posts: 10
Joined: Sat Feb 02, 2013 11:07 am

Re: Problems Using Enum

Postby skoehler » Sat Feb 09, 2013 10:48 pm

Phoen wrote:Does this mean the software on my NXT is also very old?


I have never seen any version of leJOS that reported itself as version 7.4. I am not sure what is going on. Just upgrade to 0.9.1.

Phoen wrote: I worked through a tutorial from the internet in order to set everything running.


Why did you now follow the official tutorial?
http://lejos.sourceforge.net/nxt/nxj/tutorial/index.htm

Phoen wrote: When the NXT software is to old, do have to update it too? The problem is, that I don't have a LEGO CD, where I'm not sure if that software is actually on it. Is there a page where I can find a modern NTX System in the internet? On sourcefourge maybee?


The original Lego software can be downloaded legally. It is not open source. But you don't need it. You should install leJOS 0.9.1 and then update the firmware of the NXT brick using the nxjflash tool that comes with leJOS.

Phoen wrote:So where or how do I set the bootclass path now?


Don't worry about that. Just following the tutorial on using Eclipse:
http://lejos.sourceforge.net/nxt/nxj/tu ... clipse.htm
skoehler
leJOS Team Member
 
Posts: 1104
Joined: Thu Oct 30, 2008 4:54 pm

Re: Problems Using Enum

Postby Phoen » Sat Feb 09, 2013 11:51 pm

Hello again,

thanks for all the usefull links and for all your patience.

As I messed up all the installation I now use my other computer which has nowJDK or JRE or anything else on it exept a lot of computer games :roll:
The operating system on the new PC is Windows 7 Ultimate 32 Bit, just if its necessary.

I followed exatcly the tutorial and I also wrote down what I have installed. (The last time I didn't do this and I got problems because of it)

I did install:

jdk x86 (Java SE Develoment Kit 7 Update 13)
fantom driver 1.1.3
No Bluetooth Stack - because I think I wont need it.
and the 32bit Windows leJOS NXJ 0.9.1beta-3 executable file (because as you see I'm not good in doing the preferences myself)

So when I started to flash the leJos Firmware on the in NXT I first turned my NXT on and connected it with the USB cable with my PC
The PC said: "Recognised unknown software... ... You can now use NXT..."
So that was proof that the NXT is conneted.
Then i started flashing the software onto the NXT but the program told me: "NXT not found. Please check that it's connected via USB"
The NXT is still on but I can't do nothing on it. Even when I press all buttons at once, (what is supposed to shut down the system) nothing happens. Also when I disconnect it from the PC I still can't contoll it.
The last time, following the old tutorial, I remember of pressing a secret button with a needle, which deleted everything.
I just ask, so that I don't mess up everything again. Do have to press this button now?

Regard

Felix
Phoen
New User
 
Posts: 10
Joined: Sat Feb 02, 2013 11:07 am

Re: Problems Using Enum

Postby skoehler » Sat Feb 09, 2013 11:54 pm

Sometimes, flashing fails. If it does, press the "secret button" (the one in the hole near the USB port) with a needle for at least 5 seconds. The NXT should start ticking.
Then connect the NXT via USB. Open a common prompt (Eingabeaufforderung) and type "nxjflash" and then hit Enter.
skoehler
leJOS Team Member
 
Posts: 1104
Joined: Thu Oct 30, 2008 4:54 pm

Re: Problems Using Enum

Postby Phoen » Sun Feb 10, 2013 11:44 am

Hello

after I slept 8 hours while my computer had to download eclipse I was now able to finish the instructions and everthing wokrs fine now.

Thanks for all the help,

regards

Phoen
Phoen
New User
 
Posts: 10
Joined: Sat Feb 02, 2013 11:07 am

Re: Problems Using Enum

Postby skoehler » Sun Feb 10, 2013 2:01 pm

I'm glad that everything worked out. I hope, the installation of 0.9.1 was less painful than that of 0.4 (or whetever version you were using before).
skoehler
leJOS Team Member
 
Posts: 1104
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 3 guests

more stuff