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

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

2017-02-28 19:55 627 查看
java.lang.UnsupportedClassVersionError
Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
The version number shown describes the version of the JRE the class file is compatible with.
“major.minor version 51.0 ”表示jar包是用哪个JDK版本编译的,你现在使用的JDK版本低于项目依赖jar包使用的版本
一个项目使用的JDK版本必须等于或高于项目所依赖的jar包编译所使用的JDK版本
The reported major numbers are:
Java SE 9 = 53, 53对应JDK版本为java 9Java SE 8 = 52, 52对应JDK版本为java 8Java SE 7 = 51, 51对应JDK版本为java 7Java SE 6.0 = 50, 50对应JDK版本为java 6Java SE 5.0 = 49, 49对应JDK版本为java 5JDK 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.(译)要解决实际问题,您应该尝试使用较新版本的Java JRE运行Java代码,或者向Java编译器指定目标参数,以指示编译器创建与早期Java版本兼容的代码。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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jdk java
相关文章推荐