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