Unsupported Major. Minor version 50.0

Source: Internet
Author: User
Tags unsupported

From Oracle

**************************************** **************************************** **************************************** ****************

Symptomserror java. Lang. unsupportedclassversionerror:... unsupported Major. minorversion 50.0 Cause

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 version50. 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.

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

    1. Compile the class with the same (or older) Java version as used on run-time
    2. Compile the class and use the parameters-SourceAnd-TargetTo mimic class is compiled with lower version.

For example when having Java 6 running compilation

# Javac-Source1.5-Target1.5Myclass. 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 thatJavacAndJavaExecutable are used from the same jdk_home.

Run# Which javacAnd# Which JavaTo confirm.

The environment setting path may resolveJavaFrom $ ias_oracle_home/appsutil/JDK/JRE/bin, whileJavacIs 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 useJavapUtility coming with the JDK (It's not supported with the JRE only installation)

Run# Javap-verbose <class> | grep version 

Note: provide the name without extenstion, so useMyclassInsteadMyclass. Class

Check the major version collected in below table

Major version Java
46 In Java 1.2
47 In Java 1.3
48 In Java 1.4
49 Java 5
50 Java 6
51 Java 7

 

 

 

 

 

 

 

**************************************** **************************************** **************************************** ******************************

Use the. Class file to confirm the major and minor versions.

1. Open the class file in eclipse and you can find


2. Run the javap command, for example, javap classname-verbose> C: \ major_version.txt.


Therefore, the compiling and running Java versions are the same. For example, 46 is the major version compiled by 1.4 by default, and 1.4 compiler must be used for compilation.


 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.