检查编译后的class文件的Java编译器版本(jdk版本)
Possible Duplicate:
how to check the jdk version used to compile a .class file
Hello,
I have lots of third party class files and i would like to know . with which java version, those class files were compiled ..
thanks in advance
javaamtho
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法真正检查生成类文件的编译器版本。 Java 支持编译到“目标”,该目标可能小于编译器的实际版本。这意味着,如果您在 JDK 1.6 版本中使用标志“-target 1.5”调用 javac,1.6 JDK 将生成 1.5 类文件。
但是,您可以检查该类所需的最低 JRE 版本。它在类中被写为“主要数字”。这个“主编号”占据类文件的第 7 个和第 8 个字节。 查看规范以获取更多详细信息。
48、49 和 50 分别对应于 JRE 1.4、1.5 和 1.6。
You can't really check what version of the compiler generated the class file. Java support compiling to a "Target" which might be less than the actual version of the compiler. This means that if you call javac in a JDK 1.6 release with the flag "-target 1.5" the 1.6 JDK will generate 1.5 class files.
However, you can check the mimimum JRE version the class requires. It's written as the "major number" in the class. This "major number" occupies the 7th and 8th byte of a class file. Look to the specification for more details.
48, 49, and 50 correspond to JRE 1.4, 1.5, and 1.6 respectively.
在这里看到它有解决方案
see here it having the solution