Tuesday, August 09, 2005

Java 1.4 and 1.5 compatibility problems

Recently I faced a peculiar problem when I had compiled a application using JDK 1.5 and then tried to run it inside TOMCAT running Java 1.4. And I got an runtime exception - Version mismatch -- 0.49 should be 0.48
I was bewildered, but later on searching the NET understood that the class files generated by the JDK 1.5 compiler(v 0.49) and JDK 1.4(v 0.48) compiler are not same.

My application was not using any of the new JDK 1.5 features, even then this problem was arising. I think the reason for this being the host of new features introduced in JDK1.5
For e.g. in Java 1.5, U can write:
Integer I=7; and it will compile with Java1.5 and also run inside a Java 1.5 JVM.

But if the above code is run inside a Java 1.4 JVM, then it will fail. Hence SUN has put a check to ensure that there is a runtime error shown if the class files are of different versions than that of the JVM.

No comments:

Post a Comment