我一直试图在过去一小时内安装和配置maven-3.3.3。 当我输入:
mvn --version
我在cmd中收到此错误
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)
我已经关注了官方指南,还查看了其他几个博客和论坛。
这是我的系统变量
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_45
M2_HOME = C:\Program Files\Apache Software Foundation\apache-maven-3.3.3
MAVEN_OPTS = -Xms256m -Xmx512m
我在Path变量
的末尾添加了以下行%M2_HOME%\bin;%JAVA_HOME%\bin
有人请告诉我为什么我会收到此错误。提前谢谢。
P.S
java -version
给出
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)
答案 0 :(得分:13)
您需要更新到Java 7,因为类版本51.0
表示它是为Java 7构建的。顺便说一句,这些是有效版本:
J2SE 8 - 52
J2SE 7 - 51
J2SE 6.0 - 50
J2SE 5.0 - 49
JDK 1.4 - 48
JDK 1.3 - 47
JDK 1.2 - 46
JDK 1.1 - 45