您的位置:首页 > 编程语言 > Java开发

How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

2017-09-26 16:11 579 查看
转自:https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi

The version number shown describes the version of the JRE the class file is compatible with.

The reported major numbers are:
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,
Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45


(Source: Wikipedia)

To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.

For example, in order to generate class files compatible with Java 1.4, use the following command line:
javac -target 1.4 HelloWorld.java


With newer versions of the Java compiler you are likely to get a warning about the bootstrap class path not being set. More information about this error is available in blog post New
javac warning for setting an older source without bootclasspath.

shareimprove
this answer
edited Oct
11 '16 at 18:48





Victor
Stafusa

6,11973959

answered Jul
11 '12 at 11:59





Juha
Palomäki

19.6k12534

 
143 
"The
version number shown describe which version if Java was used to compile the code." No
it does not.It shows the version of the JRE that the class file is compatible with. Using cross-compilation
options you can use a 1.7 JDK to compile code with a class version of 1.1 (through 1.7). – Andrew
Thompson Jan
10 '13 at 5:31 
73 
This answer does not explain how to
fix it as the question asked? – Jonathan
Leung Mar
5 '13 at 12:58
5 
This is a nice solution for compiling
to a previous version from Eclipse directly: stackoverflow.com/a/16345710/2091700 – Alphaaa May
23 '13 at 14:03
17 
IN eclipse project=>Proerties=>java
compiler; set "the compiler compliance level" to the version according to your jre or jdk. As for me, it's 1.6 for jre 1.6 – Sam Sep
25 '13 at 14:58 
4 
This may occur when compiler source
is set in non-compliance with currently compiling JRE/JDK. For example i found the below values from eclipse .settings folder, org.eclipse.jdt.core.compiler.compliance=1.7, org.eclipse.jdt.core.compiler.source=1.7, org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7.
And my compiler was 1.6.0_32. The problem was resolved after changing the values to 1.6. The issue originated after i copied the project from a different workspace where i was using JDK 1.7 :( – Gana Dec
22 '14 at 6:22 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐