i have a question regarding the class files which we get after compiling java files. From a calss file how can we get to know which jdk was used to compile it?
and will there be any difference between two class files which are obtained from compiling same java file on different systems but using same jdk?
it will be helpful if any one answers these questions.
Regarding your second question, the two class files will be the same even though you are compiling on different systems with same JDK.. remember java is platform independent.
And regarding your first question, even im curious to know as to how to find out which jdk version was used to compile the class had I just had the class file.
The ultimate reference for this is the JVM specification. The major and minor version numbers are bytes 7/8 and 5/6 of the class file, respectively. This page explains it with a bit more detail. A library like Javassist provides an easily usable API for getting at this information (as do others like ASM and BCEL).
Of course the classfile version number will not tell you the actual compiler used (say Sun or IBM), just the classfile format that was generated by that compiler (which is all you should have to worry about anyway, unless you suspect there's a bug in that generated bytecode in which case you should contact the person who compiled it and tell them). [ November 28, 2006: Message edited by: Jeroen T Wenting ]