Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Version of Maven is Compatible with Java 6?

Tags:

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?

like image 242
James Oravec Avatar asked Mar 21 '16 20:03

James Oravec


People also ask

Does Maven support Java 6?

Jenkins >= 1.520 (1.531. 1 for LTS) requires Java 6 thus Maven jobs must be launched with a JDK >= 6. Jenkins >= 1.612 (1.625. 1 for LTS) requires Java 7 thus Maven jobs must be launched with a JDK >= 7.

What version of Java does Maven support?

The default Java compiler version used by Maven is Java 1.5 .

What version of Maven is compatible with Java 8?

2.1. The Maven compiler accepts this command with –target and –source versions. If we want to use the Java 8 language features, the –source should be set to 1.8. Also, for the compiled classes to be compatible with JVM 1.8, the –target value should be 1.8. The default value for both of them is the 1.6 version.

Does Maven work with Java 11?

If there's some dependency that you can't update due to compatibility issues in your project than leave it as is. Chances are that it just runs fine with Java 11. Hint: You can speed up multi-module Maven projects by using parallel builds, e.g. mvn -T 4 compile compiles all modules in parallel on 4 CPU cores.


1 Answers

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.

like image 106
M A Avatar answered Sep 20 '22 03:09

M A