Possible Duplicate:
Tool to read and display Java .class versions可能的副本:用于读取和显示Java .class版本的工具
I'm trying to debug a
我在调试a
"Bad version number in .class file'
“.class文件中的错误版本号”
error in java, is there a way for me to check which version the .class
files are?
java中的错误,是否有办法检查.class文件的版本?
I'm using JRE1.5.0_6
, but my JDK
is version 1.6.0_13.
我正在使用JRE1.5.0_6,但是我的JDK是1.6.0_13版本。
I'm compiling with compatibility mode set to 1.5 in eclipse which I thought would work...
在eclipse中,我将兼容模式设置为1.5进行编译,我认为它可以工作……
5 个解决方案
#1
532
You're looking for this on the command line (for a class called MyClass):
您正在命令行中寻找它(用于一个名为MyClass的类):
On Unix/Linux:
在Unix / Linux:
javap -verbose MyClass | grep "major"
On Windows:
在Windows上:
javap -verbose MyClass | findstr "major"
You want the major version from the results. Here are some example values:
你想要结果的主要版本。下面是一些示例值:
- Java 1.2 uses major version 46
- Java 1.2使用了主要版本46
- Java 1.3 uses major version 47
- Java 1.3使用了主要版本47
- Java 1.4 uses major version 48
- Java 1.4使用了主版本48
- Java 5 uses major version 49
- Java 5使用主要版本49
- Java 6 uses major version 50
- Java 6使用主要版本50
- Java 7 uses major version 51
- Java 7使用主要版本51
- Java 8 uses major version 52
- Java 8使用主要版本52
- Java 9 uses major version 53
- Java 9使用主要版本53
- Java 10 uses major version 54
- Java 10使用主要版本54
#2
15
Btw, the reason that you're having trouble is that the java compiler recognizes two version flags. There is -source 1.5, which assumes java 1.5 level source code, and -target 1.5, which will emit java 1.5 compatible class files. You'll probably want to use both of these switches, but you definitely need -target 1.5; try double checking that eclipse is doing the right thing.
顺便说一句,您遇到麻烦的原因是java编译器识别两个版本标志。有-source 1.5,它假定java 1.5级源代码,-target 1.5,它将发出java 1.5兼容的类文件。你可能想同时使用这两个开关,但是你肯定需要-target 1.5;尝试再次检查eclipse是否做了正确的事情。
#4
5
You can try jclasslib:
你可以试试jclasslib:
https://github.com/ingokegel/jclasslib
https://github.com/ingokegel/jclasslib
It's nice that it can associate itself with *.class extension.
很高兴它能和*联系在一起。类的扩展。
#5
3
Does the -verbose
flag to your java
command yield any useful info? If not, maybe java -X
reveals something specific to your version that might help?
java命令的-verbose标志是否产生任何有用的信息?如果不是,也许java -X揭示了一些特定于您的版本可能会有所帮助的东西?
#1
532
You're looking for this on the command line (for a class called MyClass):
您正在命令行中寻找它(用于一个名为MyClass的类):
On Unix/Linux:
在Unix / Linux:
javap -verbose MyClass | grep "major"
On Windows:
在Windows上:
javap -verbose MyClass | findstr "major"
You want the major version from the results. Here are some example values:
你想要结果的主要版本。下面是一些示例值:
- Java 1.2 uses major version 46
- Java 1.2使用了主要版本46
- Java 1.3 uses major version 47
- Java 1.3使用了主要版本47
- Java 1.4 uses major version 48
- Java 1.4使用了主版本48
- Java 5 uses major version 49
- Java 5使用主要版本49
- Java 6 uses major version 50
- Java 6使用主要版本50
- Java 7 uses major version 51
- Java 7使用主要版本51
- Java 8 uses major version 52
- Java 8使用主要版本52
- Java 9 uses major version 53
- Java 9使用主要版本53
- Java 10 uses major version 54
- Java 10使用主要版本54
#2
15
Btw, the reason that you're having trouble is that the java compiler recognizes two version flags. There is -source 1.5, which assumes java 1.5 level source code, and -target 1.5, which will emit java 1.5 compatible class files. You'll probably want to use both of these switches, but you definitely need -target 1.5; try double checking that eclipse is doing the right thing.
顺便说一句,您遇到麻烦的原因是java编译器识别两个版本标志。有-source 1.5,它假定java 1.5级源代码,-target 1.5,它将发出java 1.5兼容的类文件。你可能想同时使用这两个开关,但是你肯定需要-target 1.5;尝试再次检查eclipse是否做了正确的事情。
#3
#4
5
You can try jclasslib:
你可以试试jclasslib:
https://github.com/ingokegel/jclasslib
https://github.com/ingokegel/jclasslib
It's nice that it can associate itself with *.class extension.
很高兴它能和*联系在一起。类的扩展。
#5
3
Does the -verbose
flag to your java
command yield any useful info? If not, maybe java -X
reveals something specific to your version that might help?
java命令的-verbose标志是否产生任何有用的信息?如果不是,也许java -X揭示了一些特定于您的版本可能会有所帮助的东西?