Jdk 1.6 will not compile: cannot access java.lang.Object

R

rzeira

Hi all,

I just installed Jdk 1.6 update 4 and tried my first compilation. I
compiled something that previously compiled easily. However, with Jdk
1.6 I got the error:
SomeFile.java:45: cannot access java.lang.Object
bad class file: C:\Tools\Jdk16\jre\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0
Please remove or make sure it appears in the correct subdirectory of
the classpath.
private UserRec currRec = null;

I compile directly with javac from a DOS prompt. I tried to compile
few other files and got the same results.

Please help!
 
J

Jonatan Kazmierczak

I just installed Jdk 1.6 update 4 and tried my first compilation. I
compiled something that previously compiled easily. However, with Jdk
1.6 I got the error:
SomeFile.java:45: cannot access java.lang.Object
bad class file: C:\Tools\Jdk16\jre\lib\rt.jar(java/lang/Object.class)
class file has wrong version 49.0, should be 48.0

Hi,
typical problem for window$ users - curse of PATH env. var. :)
Your OS runs old javac; correct your PATH env. var. manually or invoke
javac with full path.
And better switch your OS to something normal, Linux-based, like Mepis.
 
R

Roedy Green

SomeFile.java:45: cannot access java.lang.Object

For a brute force fix, uninstall all JREs and JDKs. Manually prune
any left over directories. then reinstall just one JDK from scratch.

Note JDK 1.6.0_04 just came out so you might as well use that.

Check any set parms for outdated references.
 
L

Lew

(multi-post unified)


As Juha Laiho said,
(e-mail address removed) replied:
However, I have only one javac.exe which came with JDK 1.6.0_04 and is
dated December 14, 2007. I think this version is defective. Does
anybody knows how to get one that is fixed?

Unfortunately, Juha must be correct. There is another javac in your path and
it's not able to read the current classfile format (version 49.0). That means
that it's a compiler from an earlier version than Java 6, let alone update 4.

In fact, it looks like class file version 48.0 is from JDK 1.4. So there is a
version 1.4 of the JDK trying to read the Java 6 libraries and choking.

It seems that this is a FAQ going back to 2004 at least.
<http://forum.java.sun.com/thread.jspa?threadID=517933&tstart=0>

Pop "Java class file version 49.0" into your favorite search engine and see
what you find - probably more like that page that showed up in my search.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top