Backward compatible issues in JDK 1.5
Hi,
One of my .java file was getting compiled and executing properly in JDK 1.4.2. But the same java file when using a dependent jar generated with java version "1.5.0_01" and get compiled by JDK 1.4.2, I am getting this compilation error
"class file has wrong version 49.0, should be 48.0".
I have both JDK 1.4 and 1.5 installed in my box and in Windows XP registry the CurrentVersion of Java Development Kit have a value 1.5.
Please help on this.
Regds.
> Hi,
> One of my .java file was getting compiled and
> executing properly in JDK 1.4.2. But the same java
> file when using a dependent jar generated with java
> version "1.5.0_01" and get compiled by JDK 1.4.2, I
> am getting this compilation error
>
> "class file has wrong version 49.0, should be 48.0".
>
> I have both JDK 1.4 and 1.5 installed in my box and
> in Windows XP registry the CurrentVersion of Java
> Development Kit have a value 1.5.
>
> Please help on this.
>
> Regds.
Can you share what IDE you are using? If you are compiling your code using JBuilderX or older with JDK 1.5.0, you will get this error because JBuilderX does not support the JDK1.5 completely (even after installing a free upgrade available on borland developers website).
You code is expecting a newer version (49.0) of class files while compiling in JDK 1.4.2 (where java.class.version = 48.0). Since the jar file compiled on JDK 1.5 keeps references to the newer classes used. You need to create the jar in 1.4.2 to run it on 1.4.2.
If Using JbuilderX:In the Help--> About menu on JbuilderX, go to the info option in the tree on the left pane. A list of available features will be shown on the right. Look for java.class.version property, its value will be shown as 48.0. If it shown 49.0 then your code should work.
Ahmed
You say you're trying to compile a classfile using the 1.4 compiler yet you are referring in your classpath to a library compiled with the 1.5 compiler.
And there's your problem, as the 1.4 compiler cannot read the 1.5 classfile format.
This has NOTHING to do with backwards compatibility.
What you are expecting is FORWARD compatibility, an eternally unchangable classfile format.
Yes this is a forward binary compatiblity case which I was trying to do in a wrong way.
I hope forward compatiblity should not be practically feasible to support. The Backward binary compatibilty is the feature which should be provided. Am I correct on this assumption?
Fortunatly I was going thru this page
http://java.sun.com/j2se/1.5.0/compatibility.htmlwhich gives some information about compatibility.
regds
yes, classfiles are compatible with later versions of the runtime (a few very rare exceptions might exist, so you should always test, but those are more likely if you do obscure things with JNI and reflection).
Hi,
If you are using JBuilderX, I found that using the following plugin;
http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=21447
and the following advice
http://threads.borland.com/threads/threads.exe/thread?refid=23160&view=full text
did the trick.
(I too was having the 48.0 and 49.0 problem).