Can I inspect java code and determin开发者_JAVA百科e what runtime it will be able to run on? For instance I want to make sure all applications in our environment are using Sun SE6 and JDK 1.6.
When you run the "javap -verbose" on any class, you will get a major and a minor version numbers. Following is a mapping between major+minor to an actual java jre version.
major minor Java platform version
45 3 1.0
45 3 1.1
46 0 1.2
47 0 1.3
48 0 1.4
49 0 1.5
50 0 1.6
If you want to programatically get the class version, you can follow this link: Java API to find out the JDK version a class file is compiled for?
javap might be what you want:
javap -verbose MyClass
精彩评论