简体   繁体   中英

What Version of Maven is Compatible with Java 6?

I have to work in an older project that requires java 6 to run, as there are references to depreciated sun classes that have been removed in future versions. As part of the process, I changed my jdk from 8 in my system path to point to java 6 jdk. After doing so I get:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    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(ClassRealm.java:401)
    at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
    at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(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(Launcher.java:144)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 

This is is similar to Maven Installation OSX Error Unsupported major.minor version 51.0 and Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0) however I'm not looking to upgrade, I'm looking to find a version of maven that is compatible with java 6. Any ideas on which version is compatible and where I can download/install it from for mac?

According to the Maven release history page , the last Maven version that works with JDK1.6 is 3.2.5.

Note that it's better to keep using the newer Maven version (and keep Java 8 as the default in the system path), and tell Maven that the project it's building should compile with source set to 1.6 - see source and target documentation for more info. Reverting to an old Maven will remove the bug fixes / enhancements of the newer versions.

如果您遇到问题,则需要使用JDK 6构建,但是您希望使用JDK 7运行Maven(因为您希望使用Maven 3.3+),您应该考虑使用工具链 ,这使得它彼此独立。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM