Description
在下载 Maven包,配置了环境变量之后,在命令行执行 mvn -version(or -v) 报错:
1 Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/ma 2 ven/cli/MavenCli : Unsupported major.minor version 51.0 3 at java.lang.ClassLoader.defineClass1(Native Method) 4 at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) 5 at java.lang.ClassLoader.defineClass(ClassLoader.java:616) 6 at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 7 1) 8 at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) 9 at java.net.URLClassLoader.access$000(URLClassLoader.java:58) 10 at java.net.URLClassLoader$1.run(URLClassLoader.java:197) 11 at java.security.AccessController.doPrivileged(Native Method) 12 at java.net.URLClassLoader.findClass(URLClassLoader.java:190) 13 at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(Cl 14 assRealm.java:401) 15 at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass( 16 SelfFirstStrategy.java:42) 17 at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadCl 18 ass(ClassRealm.java:271) 19 at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm 20 .java:254) 21 at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm 22 .java:239) 23 at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launch 24 er.java:144) 25 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun 26 cher.java:266) 27 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav 28 a:229) 29 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La 30 uncher.java:415) 31 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java: 32 356)
Caused By
JAVA_HOME 中 jdk版本过低。虽然用的是 jdk6,但我下载的 maven 是最新的 3.3.9,把环境变量中的 JAVA_HOME 指向 jdk8,结果正常。
Solution
提高 JAVA_HOME 中 jdk 版本。
时间: 2024-10-14 21:42:33