What version of javac built my jar?

前端 未结 20 916
孤街浪徒
孤街浪徒 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条回答
  •  Happy的楠姐
    2020-11-27 10:36

    A good deal of times, you might be looking at whole jar files, or war files that contain many jar files in addition to themselves.

    Because I didn't want to hand check each class, I wrote a java program to do that:

    https://github.com/Nthalk/WhatJDK

    ./whatjdk some.war
    some.war:WEB-INF/lib/xml-apis-1.4.01.jar contains classes compatible with Java1.1
    some.war contains classes compatible with Java1.6
    

    While this doesn't say what the class was compiled WITH, it determines what JDK's will be able to LOAD the classes, which is probably what you wanted to begin with.

提交回复
热议问题