jar file , which jdk version ?

I have a question that i want to ask for a long time. Let say someone give you a jar file, how do we check which version of JDK it is compile ?
[150 byte] By [michlooia] at [2007-11-27 8:24:02]
# 1

You can get an easy, but approximate, answer by looking in the jar manifest:

$ jar -xf somejar.jar META-INF/MANIFEST.MF

$ cat META-INF/MANIFEST.MF

Manifest-Version: 1.0

Class-Path: someotherjar.jar

Created-By: 1.6.0 (Sun Microsystems Inc.)

Main-Class: Main

The Created-By attribute says which JDK version created the jar file. However, that's not always the same as the version that was used to compile the classes. To get an exact answer, you'd need to look at the class file version number, and you'd have to do it for each class file since they don't all have to be the same. Gory details left as an exercise. Here's a reference to get you started:

http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#80959

jxca at 2007-7-12 20:13:00 > top of Java-index,Desktop,Runtime Environment...