Java API to find out the JDK version a class file is compiled for?

前端 未结 8 991
星月不相逢
星月不相逢 2020-11-28 07:52

Are there any Java APIs to find out the JDK version a class file is compiled for? Of course there is the javap tool to find out the major version as mentioned in here. Howev

8条回答
  •  眼角桃花
    2020-11-28 08:07

    On Linux, you can use the file command on a class file, which I found easiest for my use case. For example:

    $ file Foo.class
    Foo.class: compiled Java class data, version 50.0 (Java 1.6)
    

提交回复
热议问题