[Solved] nxjc error (0.9.0) in windows 7

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

Moderators: roger, 99jonathan, imaqine

[Solved] nxjc error (0.9.0) in windows 7

Postby cgc » Mon Feb 27, 2012 10:21 pm

Hello!
I have a NXT 2.0 with leJOS 0.9.0 (it's not mine so I can't upgrade).

I'm using windows 7 and I've installed and reinstalled the java and it seem to work okay, but when I compile with nxjc v0.9.0 I always recieve 100 errors (compiling for example the HelloWorld sample).
This errors are like:
Code: Select all
java\lang\Class.java(java\lang:Class.java):37: package sun.misc does not exist
import sun.misc.Unsafe;
               ^
java\lang\Class.java(java\lang:Class.java):38: package sun.reflect does not exist
import sun.reflect.ConstantPool;
                  ^
java\lang\Class.java(java\lang:Class.java):39: package sun.reflect does not exist
import sun.reflect.Reflection;
                  ^
java\lang\Class.java(java\lang:Class.java):40: package sun.reflect does not exist
import sun.reflect.ReflectionFactory;
                  ^
java\lang\Class.java(java\lang:Class.java):41: package sun.reflect does not exist
import sun.reflect.SignatureIterator;
                  ^
java\lang\Class.java(java\lang:Class.java):42: package sun.reflect.generics.factory does not exist
import sun.reflect.generics.factory.CoreReflectionFactory;
                                   ^
java\lang\Class.java(java\lang:Class.java):43: package sun.reflect.generics.factory does not exist
import sun.reflect.generics.factory.GenericsFactory;
                                   ^
java\lang\Class.java(java\lang:Class.java):44: package sun.reflect.generics.repository does not exist
import sun.reflect.generics.repository.ClassRepository;
                                      ^
java\lang\Class.java(java\lang:Class.java):45: package sun.reflect.generics.repository does not exist
import sun.reflect.generics.repository.MethodRepository;
                                      ^
java\lang\Class.java(java\lang:Class.java):46: package sun.reflect.generics.repository does not exist
import sun.reflect.generics.repository.ConstructorRepository;
                                      ^
java\lang\Class.java(java\lang:Class.java):47: package sun.reflect.generics.scope does not exist
import sun.reflect.generics.scope.ClassScope;
                                 ^
java\lang\Class.java(java\lang:Class.java):48: package sun.security.util does not exist
import sun.security.util.SecurityConstants;
                        ^
java\lang\Class.java(java\lang:Class.java):50: package sun.reflect.annotation does not exist
import sun.reflect.annotation.*;


And so on. I know some people who has installed it in a windows 7 x64 pc and it works for him.
I firstly installed the version 0.9.1 and in that version compiles okay, so i'm completely lost about what can it be.

I also wanted to ask if I upgrade it to 0.9.1, can I downgrade it again to 0.9.0?

Thanks.
Last edited by cgc on Thu Mar 01, 2012 4:35 pm, edited 3 times in total.
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby skoehler » Mon Feb 27, 2012 10:41 pm

cgc wrote:Hello!
I have a NXT 2.0 with leJOS 0.9.0 (it's not mine so I can't upgrade).

I'm using windows 7 and I've installed and reinstalled the java and it seem to work okay, but when I compile with nxjc v0.9.0 I always recieve 100 errors (compiling for example the HelloWorld sample).
This errors are like:
Code: Select all
java\lang\Class.java(java\lang:Class.java):37: package sun.misc does not exist
import sun.misc.Unsafe;
               ^


You obviously seem to be compiling source code that is part of Sun/Oracle's JDK. I have no idea how that happened. Please post the nxjc command line that you are using. Also, in which location is java\lang\Class.java which contains that import statement and how did it get there?

I have the impression, that you need to clean up. You need to delete all those sources by Oracle. When you invoke nxjc, there must only be your own code in the folder.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: nxjc error (0.9.0) in windows 7

Postby cgc » Tue Feb 28, 2012 3:23 pm

I was compiling the HelloWorld example in the project folder that leJOS installed in my user folder. The code there is:

Code: Select all
package org.lejos.example;

import lejos.nxt.*;

/**
 * Example leJOS Project with an ant build file
 *
 */
public class HelloWorld {

   public static void main(String[] args) {
      System.out.println("Hello World");
      Button.waitForPress();
   }
}


And I compile it typing "nxjc HelloWorld.java" and then all these errors come out. Whit the version 0.9.1 that errors doesn't appears and it seem to compile, so I have no idea of what is really happening. And well, yesterday I uninstalled the jdk and jre and reinstalled it again.

Finally, that class.java is in "C:\Program Files (x86)\Java\jdk1.6.0_31\src.zip" in where the libraries are. Thanks for your help! :)
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby cgc » Thu Mar 01, 2012 1:01 pm

Any idea about that?
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby skoehler » Thu Mar 01, 2012 1:12 pm

cgc wrote:Any idea about that?

I am sorry, but I have no idea what causes this.
Here's what happens: As you can see by looking at nxjc.bat, nxjc simply invokes javac. Now javac prints all those array messages you posted. And those error messages clearly contain fragments of Java source files, which belong to the JDK. javac is not supposed to load them. If you didn't unpack src.zip somewhere, then javac won't even have access to the JDK sources (javac doesn't load sources from zip/jar files, AFAIK).

So here's what I suggest to further debug this:
use "nxjc -verbose HelloWorld.java" and post the output.

It will tell us, where javac is looking for sources, class files, and which it actually loads.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: nxjc error (0.9.0) in windows 7

Postby cgc » Thu Mar 01, 2012 2:38 pm

Well, I think that javac can unpack zip files, as it seem in that folder is where the libraries are, and I can compile other sources, but I'm not sure at all.
Thats the output you asked for: http://pastebin.com/1z0FFZvE (it was too large for the forum)


Thanks for your help! :)
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby skoehler » Thu Mar 01, 2012 2:56 pm

Yes, I was wrong. Apparently, the sourcepath can include zips and jars.

Please open a command prompt (the one that you would usually execte nxjc in) and provide a dump of your environment variables. You can get a list of the variables and their values by executing the command "set".
What you pasted is proof that your system is seriously misconfigured.

JAR files (which usually contain class files but no source files) are part of the sourcepath. And ZIP files (like src.zip, which contain no class files but no source files) are part of the classpath.

Update: it is javac, which automatically adds the contents of the CLASSPATH variable to BOTH the classpath and the sourcepath. So the fact that JAR files are on the source path is kind of correct. But that the src.zip is part of the CLASSPATH variable is incorrect. Simply remove it, and you should be good to go!

In future versions of leJOS, scripts like nxjc.bat will automatically clear the CLASSPATH variable before invoking javac.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: nxjc error (0.9.0) in windows 7

Postby cgc » Thu Mar 01, 2012 4:09 pm

Wow it seem to work now!!
I put the src.zip because of a tutorial. I found several tutorials on how to install the jdk where they say to put the path to src.zip in the classpath! That tutorials I used were in spanish, but I found a lot! What a strange thing...
Can I ask you some things?
Why in verison 0.9.1 worked? (is it because of what you said of future versions of leJOS?)
Why do you think that tutorials made the classpath to point src.zip? And what other problems could I have if I haven't taken it out?
And well, what is that src.zip used for if it isn't for linking or anything?

Thanks a lot again! You've helped me very much! :D I've been thinking about it since I posted it and I tired of it.
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby skoehler » Thu Mar 01, 2012 4:17 pm

cgc wrote:Wow it seem to work now!!
I put the src.zip because of a tutorial. I found several tutorials on how to install the jdk where they say to put the path to src.zip in the classpath! That tutorials I used were in spanish, but I found a lot! What a strange thing...


Very strange indeed!

cgc wrote:Can I ask you some things?
Why in verison 0.9.1 worked? (is it because of what you said of future versions of leJOS?)


I'm not sure. 0.9.1 didn't contain any workaround for that.

cgc wrote:Why do you think that tutorials made the classpath to point src.zip? And what other problems could I have if I haven't taken it out?


Give me a link to the tutorial. I will have a quick look, whether the src.zip on CLASSPATH surves any purpose.
Is the tutorial only about installing the JDK? Or is it about how to install the JDK and to configure the system for some sort of 3rdparty application?

cgc wrote:And well, what is that src.zip used for if it isn't for linking or anything?


src.zip is for debugging purposes. E.g. if you're using Eclipse, and step through your source, your can actually step into methods like ArrayList.toString() - the sources are then takes from src.zip.
Never ever - at no point in time - you would have to recompile any of the classes in src.zip.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: nxjc error (0.9.0) in windows 7

Postby cgc » Thu Mar 01, 2012 4:32 pm

skoehler wrote:Give me a link to the tutorial. I will have a quick look, whether the src.zip on CLASSPATH surves any purpose.
Is the tutorial only about installing the JDK? Or is it about how to install the JDK and to configure the system for some sort of 3rdparty application?

Here are 3 tutorials saying it. I haven't found spanish tutorials without the src.zip part, some pointed to one of the following 3.
http://www.luiskano.net/blog/2010/04/28 ... windows-7/
http://iwokloco-appweb.blogspot.com/201 ... dk-en.html
http://foro.universojuegos.es/viewtopic.php?f=74&t=3145

It seem it is only for installing the JDK, some of them says that IDEs exist, but it doesn't say anything more about that or 3rdparty applications.

skoehler wrote:src.zip is for debugging purposes. E.g. if you're using Eclipse, and step through your source, your can actually step into methods like ArrayList.toString() - the sources are then takes from src.zip.
Never ever - at no point in time - you would have to recompile any of the classes in src.zip.

And I suppose that Eclipse keep itself track of that zip file? Or maybe the reason for putting src.zip in the classpath is for something like that?
(Eclipse wasn't working with leJOS, I think that's because of Eclipse is x64 and it doesn't find the driver and that kind of problems, but I'll have the nxt for few months so it isn't a problem to compile through the command line, if some day I buy one nxt then I'll see what happens... or I'll post it here :P )

Thanks for all again, I'll mark the topic as solved.
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm

Re: nxjc error (0.9.0) in windows 7

Postby skoehler » Thu Mar 01, 2012 4:40 pm

cgc wrote:
skoehler wrote:Give me a link to the tutorial. I will have a quick look, whether the src.zip on CLASSPATH surves any purpose.
Is the tutorial only about installing the JDK? Or is it about how to install the JDK and to configure the system for some sort of 3rdparty application?

Here are 3 tutorials saying it. I haven't found spanish tutorials without the src.zip part, some pointed to one of the following 3.
http://www.luiskano.net/blog/2010/04/28 ... windows-7/
http://iwokloco-appweb.blogspot.com/201 ... dk-en.html
http://foro.universojuegos.es/viewtopic.php?f=74&t=3145

It seem it is only for installing the JDK, some of them says that IDEs exist, but it doesn't say anything more about that or 3rdparty applications.


I took a look. Don't follow these tutorials. Download the JDK from Oracle. Run the Installer. And be happy. I can assure you, that no software will require the modifications these tutorials suggest!
I cannot tell, where this misconception originated, but tools that require the location of tools.jar (like Ant) or of src.zip (like Eclipse) will compute the locations by themselves. There is no need to misconfigure your system in the way these tutorials suggest.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: [Solved] nxjc error (0.9.0) in windows 7

Postby cgc » Thu Mar 01, 2012 5:05 pm

Well, I don't know why I followed them. I did the first time I installed the JDK (I suppose because it didn't worked at first time or I don't know) and well, when I reinstalled it I remebered that I had to edit the environment variables and I looked for it again. I found it quite strange, as most installers edit that variables by itserlf (I think java JRE does), but well I found I had to edit them and I did.
Thanks for your help! I've learnt a bit on that things in the java compiler, and now I can compile the leJOS sources so it's fantastic! :D
cgc
New User
 
Posts: 7
Joined: Mon Feb 27, 2012 10:15 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 3 guests

more stuff