"Java.lang.UnsupportedClassVersionError" Version inconsistency error

Source: Internet
Author: User

All error messages for this bug:

1 java.lang.unsupportedclassversionerror:org/apache/lucene/store/directory:unsupported major.minor version 51.0 2 At  Java.lang.ClassLoader.defineClass1 (Native Method) 3 at  Java.lang.ClassLoader.defineClassCond ( classloader.java:631) 4 at  Java.lang.ClassLoader.defineClass (classloader.java:615) 5  at Java.security.SecureClassLoader.defineClass (secureclassloader.java:141) 6 at  Java.net.URLClassLoader.defineClass (urlclassloader.java:283) 7 at  java.net.urlclassloader.access$000 ( URLCLASSLOADER.JAVA:58) 8 at  Java.net.urlclassloader$1.run (urlclassloader.java:197) 9  at Java.security.AccessController.doPrivileged (Native Method) at  Java.net.URLClassLoader.findClass ( urlclassloader.java:190) at  java.lang.ClassLoader.loadClass (classloader.java:306)  Sun.misc.launcher$appclassloader.loadclass (launcher.java:301) 13  

Reading the wrong message is because the jar package you are using is not the correct version. What is this 51.0?

Different versions of the JDK, the compiled class files are different. By looking at the first few bytes of the analysis class file, you can find the corresponding relationship, the detailed reference official, the minor version may have the difference:

1 J2SE 7 = 0x33 Hex, 2 j2se 6.0 = (0x32 hex), 3 J2SE 5.0 = (0x31 hex), 4 jdk 1.4 = (0x30 hex), 5 jdk 1.3 = 47 (0 x2f hex), 6 jdk 1.2 = (0x2e hex), 7 JDK 1.1 = (0x2D hex).
Observe the error:

Originally my eclipse JDK was 1.6, but the jar package clearly requires 1.7, of course, it will go wrong!

So, how to correct it? Download the 1.7 version of the JDK without saying it.

Right-click Project Engineering, Properties

Click JRE Library

Modifying the JDK version

Finally compiled successfully!

"Java.lang.UnsupportedClassVersionError" Version inconsistency error

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.