What version of javac built my jar?

前端 未结 20 894
孤街浪徒
孤街浪徒 2020-11-27 09:48

How can I tell what version of the Java compiler was used to build a jar? I have a jar file, and it could have been built in any one of three JDKs. We need to know exactly

20条回答
  •  粉色の甜心
    2020-11-27 10:40

    You can't tell from the JAR file itself, necessarily.

    Download a hex editor and open one of the class files inside the JAR and look at byte offsets 4 through 7. The version information is built in.

    http://en.wikipedia.org/wiki/Java_class_file

    Note: As mentioned in the comment below,

    those bytes tell you what version the class has been compiled FOR, not what version compiled it.

提交回复
热议问题