5.0 RC: does not compile (cannot access java.lang.Object)

I tried to compile my project with JDK 5.0 RC (that works with JDK 1.4.2_05), but it doesn't work:

[javac] cannot access java.lang.Object

[javac] badclass file: C:\Programme\Sun\Java\J2SE\JRE\jre1.5.0rc\lib\rt.jar(java/lang/Object.class)

[javac]class file has wrong version 49.0, should be 48.0

[javac] Please remove or make sure it appears in the correct subdirectory of the classpath.

[javac]staticpublicfinal String FORMAT_DATE ="yyyy-MM-dd";

[javac] ^

[javac] 1 error

Of course, i first adjusted two compilation errors for the new classes Formatter und UUID (that collided with my own classes). I also deleted all class files and did a fresh compile. But it doesn't help.

[927 byte] By [MartinHilpert] at [2007-9-30 17:08:53]
# 1
The problem seems to be that you use the compiler from 1.4.2 but have somehow set it up to use the classes of 1.5.0. Old compiler can't use new classes.
jsalonen at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 2
I didn't set up any such complicated things. I just installed 1.5 RC. "java -version" also shows the correct new version.
MartinHilpert at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 3
Well, I guess you were right: my ant script in Eclipse used another JDK. I thought i just had to configure the JDK once in Eclipse, but you also have to adjust the ANT classpath to use the right tools.jar :-(
MartinHilpert at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 4

... however, I'm not able to change back to JDK 1.4 after I installed JDK 5.0. I get the same error now after reverting back to 1.4. I also noticed that in a console, "java -version" always shows the 5.0 version - no matter if my JAVA_HOME is set to 1.4 and this is also in my PATH. I found a "java.exe" file in the C:/WINNT/SYSTEM32 that is from version 5.0.

MartinHilpert at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 5

You must have installed a public JRE aswell when you installed JDK 5.0. The public JRE installs a copy of java.exe and javaw.exe to a system directory so that it's not necessary to set PATH to run java programs.

How have you set up your PATH? You should move the Java SDK directory before the system directories; that way you get your desired version. Also, the version of "javac" may be different than version of "java" can be checked with javac -J-version.

What comes to ANT, I thought you only need to set JAVA_HOME, if you are using ANT through Eclipse it's probably some setting in Eclipse that you have to change...

jsalonen at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 6
I tried the workaround by setting the JAVA_HOME as the first entry in my PATH, but this also doesn't work. I ended up deinstalling 5.0 which also copied the 142 version of java.exe in the c:/winnt/system32 directory.
MartinHilpert at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...
# 7

How is java getting into c:/winnt/system32? And you speak of compiling. Where is your javac?

JAVA_HOME in your PATH doesn't do it but

set PATH=%JAVA_HOME%/bin

will if javac and java are in the jdk bin folder.

Also when you are working with 1.5.x source code you need to set the target to 1.5 or 5 http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javac.html

Martin3 at 2007-7-6 13:28:53 > top of Java-index,Administration Tools,Sun Connection...