f



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

Hi all,I just installed Jdk 1.6 update 4 and tried my first compilation. Icompiled something that previously compiled easily. However, with Jdk1.6 I got the error:SomeFile.java:45: cannot access java.lang.Objectbad class file: C:\Tools\Jdk16\jre\lib\rt.jar(java/lang/Object.class)class file has wrong version 49.0, should be 48.0Please remove or make sure it appears in the correct subdirectory ofthe classpath.	private UserRec currRec = null;I compile directly with javac from a DOS prompt. I tried to compilefew other files and got the same results.Please help!
0
rzeira
1/17/2008 3:14:20 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

4 Replies
2047 Views

Similar Articles

[PageSpeed] 55

rzeira@comcast.net wrote:> 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.0Hi,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.-- Regards,Jonatan KazmierczakSCJP SCJD TC_rated_memberAsm86 Bash C/C++ Java JavaScript Pascal Perl PHP Ruby TCL VB VBScript
0
Jonatan
1/17/2008 5:07:57 PM
On Thu, 17 Jan 2008 07:14:20 -0800 (PST), rzeira@comcast.net wrote,quoted or indirectly quoted someone who said :>SomeFile.java:45: cannot access java.lang.ObjectFor a brute force fix, uninstall all JREs and JDKs.  Manually pruneany 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.-- Roedy Green, Canadian Mind ProductsThe Java Glossary, http://mindprod.com
0
Roedy
1/17/2008 5:59:07 PM
On Thu, 17 Jan 2008 07:14:20 -0800 (PST), rzeira@comcast.net wrote,
quoted or indirectly quoted someone who said :

>I just installed Jdk 1.6 update 4 and tried my first compilatio

see http://mindprod.com/jgloss/jdk.html#UPGRADING
-- 
Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com
0
Roedy
1/17/2008 6:17:27 PM
(multi-post unified)

rzeira@comcast.net wrote:
>>> 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!

As Juha Laiho said,
>> Looks much like the "javac" executable you're running is from some
>> older JDK version. Check each directory on your %PATH% to find out
>> which javac you're actually running.

rzeira@comcast.net 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.

<http://java.sun.com/javase/6/docs/technotes/guides/vm/enhancements.html>
> The J2SE 1.4.0 platform accepts class file versions in the range 45.3 to 48.0.

<http://en.wikipedia.org/wiki/Class_(file_format)>
> major version number of the class file format being used. 
> J2SE 6.0=50, J2SE 5.0=49, JDK 1.4=48, JDK 1.3=47, JDK 1.2=46.

-- 
Lew
0
Lew
1/17/2008 6:35:47 PM
Reply: