开发者

is there difference between classes compiled with java 1.5 and 1.5.0_06

I have compiled a class with java version 1.5.

When i deployed it in the server it gave me bad version error.

If i compile it with java version 1.5.0_06 does that make a difference if the server is having java of version 1.5.0_06

1.Does the last number in version also make the difference??

2.javap -verbose ClassName gives me the minor and major version but how to know with which update the class is compiled with??

Than开发者_Python百科ks, Sandeep


The JRE/JDK 1.5.0_06 is an implementation of Java 1.5 (or Java 5, depending on which day of the week it is).

So no, there is no difference, classes compiled for Java 1.5 should work just fine on that version.

The class version won't tell you which update of the JDK the class was compiled with, and that information should also not be relevant.


Compile a class (any class) with both JDK 1.5 and JDK 1.5.0_06. Then compare the major/minor version of the one compiled with 1.5 with the one compiled with 1.5.0_06. If they were identical, you should be fine running the class compiled with 1.5 on a server that uses Java 1.5.0_06. Otherwise you can not.


1.Does the last number in version also make the difference??

No. It should not. However, I have faced issues at runtime due to minor version differences. On further investigation, it was found to be due to incomplete understanding of APIs. The developer was expecting obj.getClass().getFields() to return the fields in the order of declaration and it was working that way in one version. In the newer update it was returning the fields in a different order. The API clearly says that "The elements in the array returned are not sorted and are not in any particular order."
Moral of the story: Always develop,test and deploy on the exact same version of Java.

2.javap -verbose ClassName gives me the minor and major version but how to know with which update the class is compiled with??

You cannot. The class file does not even carry that information. See the class-file format: http://en.wikipedia.org/wiki/Java_class_file

The problem that you are getting looks weird. Please post your solution if you get one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜