• Post Reply Bookmark Topic Watch Topic
  • New Topic

java version of .class file  RSS feed

 
michael modenese
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
i have a question concerning the jdk version i used to compile and jar my project. is there a way to find out from the jar file with what version the project has been compiled ? the "Created-By:" (example : Created-By: 1.5.0_09-b01 (Sun Microsystems Inc.)) from the manifest file in my jar is the version of my jar tool.

thanks, mike
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if this helps:
...every .class file you generate contains a version stamp: two unsigned short integers starting at byte offset 4, right after the 0xCAFEBABE magic number. They are the major/minor version numbers of the class format...

Ref: JavaWorld - What Version is Your Java Code? (2003).

Related: JavaWorld - Magic and version numbers (1996).
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, my second reference above is from a JavaWorld article, The Java classfile lifestyle, which (despite being over 10 years old) provides a very interesting and accessible overview of the .class file structure.

A more technical version can be found in the JVM Spec.
[ January 23, 2007: Message edited by: marc weber ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!