Unsupported major.minor version 50.0
来源:互联网 发布:周扬青淘宝店 卖什么 编辑:程序博客网 时间:2024/05/22 15:11
以下摘自Oracle
****************************************************************************************************************************************
Symptoms
error java.lang.UnsupportedClassVersionError: ...Unsupported major.minorversion 50.0Cause
The exception "Unsupported major.minor version <yy>.0" is raised when the run-time Java release is a lower than the Java release used to compile the class.
For example a class compiled using Java 6 (major.minor = 50.0) can not be run with Java 5 (major.minor = 49.0) or Java 1.4.2 (major.minor = 48.0) and thus raises
Unsupported major.minor version 50.0
Note that no exception is raised when class is compiled with Java 5 (major.minor = 49.0) and then run with Java 6 (major.minor = 50.0). It's fine to run the class with a newer Java version than it was compiled with.
Solution
To resolve the error the class needs to be compiled using the same or lower Java release as used on run-time. There are 2 options to accomplish this
- Compile the class with the same (or older) Java version as used on run-time
- Compile the class and use the parameters -source and -target to mimic class is compiled with lower version.
For example when having Java 6 running compilation as
# javac -source 1.5 -target 1.5 myclass.java
makes that the both source (.java) and target (.class) are interpreted as Java 5 and class will reference major.minor = 49.0 (see below table)
Hints and tips:
- Ensure that the javac and java executable are used from the same JDK_HOME.
Run # which javac and # which java to confirm.
The environment setting PATH may resolve java from $IAS_ORACLE_HOME/appsutil/jdk/jre/bin, while thejavac is located in $IAS_ORACLE_HOME/appsutil/jdk/bin. This causes that the javac is taken from another JDK_HOME which may have a different (and possible newer) Java version. To prevent this add the $IAS_ORACLE_HOME/appsutil/jdk/bin at the start of the PATH settin, so javac is used from the correct JDK_HOME
- To verify the version class is compiled use the javap utility coming with the JDK ( it's not included with the JRE only installation)
Run # javap -verbose <class> | grep version
note: provide the name without extenstion, so use myclass instead of myclass.class
Check the major version collected in below table
Major versionJava46Java 1.247Java 1.348Java 1.449Java 550Java 651Java 7
******************************************************************************************************************************************************
通过.class文件确认major,minor版本的方法
1.在eclipse中打开class文件,可查到
2.通过javap命令查看,例如javap classname -verbose > C:\major_version.txt
因此,编译及运行的java版本相同,例如,46是1.4默认编译的major版本,需要使用1.4 compiler进行编译
- Unsupported major.minor version 50.0
- Unsupported major.minor version 50.0
- Unsupported major.minor version
- Unsupported major.minor version
- Unsupported major.minor version
- java Unsupported major.minor version 50.0
- Unsupported major.minor version 51.0Unsupported major.minor version 51.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- Unsupported major.minor version 49.0
- unsupported major.minor version 解决方法
- spring p标签是spring内置
- 线段树
- iOS7中容易被忽视的新特性(摘自cocoaChina)
- 源码下载回来是.git文件夹时处理方式
- linux awk命令详解
- Unsupported major.minor version 50.0
- [水]ZOJ1763
- cut命令详解
- 一道简单的支付宝面试题
- 鸡尾酒排序(双向冒泡排序)
- Android中Context详解——你所不知道的Context
- 设备显示sp_helpdevice
- UML 基础: 类图
- hdu1061