• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Class files related

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ,

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.

thanks
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You will find the following thread useful.
 
He's giving us the slip! Quick! Grab this tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic