什么版本的 javac 构建了我的 jar? [英] What version of javac built my jar?

查看:16
本文介绍了什么版本的 javac 构建了我的 jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何知道构建 jar 时使用的是哪个版本的 Java 编译器?我有一个 jar 文件,它可以用三个 JDK 中的任何一个构建.我们需要确切地知道是哪一个,以便我们可以证明兼容性.编译器版本是否嵌入在类文件或 jar 中的某处?

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 which one, so we can certify compatibility. Is the compiler version embedded somewhere in the class files or jar?

推荐答案

你不一定能从 JAR 文件本身分辨出来.

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

下载一个十六进制编辑器并打开 JAR 中的一个类文件并查看字节偏移量 4 到 7.版本信息是内置的.

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.

这篇关于什么版本的 javac 构建了我的 jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆