Tag Archives: MVN – version error

[Solved] MVN – version error: Exception in thread “main” java.lang.UnsupportedClassVersionError

Installing Maven is actually very simple, that is, download the required Maven package on the Apache official website, and then configure the environment variables to run (These tools are so convenient now. You don’t have to install it. You can’t tell what registry is.)

After configuration, open the command line excitedly: “MVN – version” reports an error

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/ma
ven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl
assRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl
ass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm
.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launch
er.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
356)

 

The reason is that my java version is too low and my Maven version is too high Maven compiled by a higher version of Java runs on a lower version of Java this problem will occur

If you know the problem, you can suit the remedy to the case. I have two schemes: one is to upgrade the Java version, and the other is to download the lower version of Maven again

I changed from Maven 3.3.3 to Maven 3.0.5, and the command was executed successfully

C:\Users\Administrator>mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:
28+0800)
Maven home: D:\apache-maven-3.0.5\bin\..
Java version: 1.6.0_43, vendor: Sun Microsystems Inc.
Java home: D:\Program Files (x86)\Java\jdk1.6.0_43\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"