0

I cannot get the following command to run successfully on my Yosemite 10.10.5 machine.

mvn -version

I get this error:

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)

I've googled around and every indicates its a problem with my JAVA_HOME directory but I cannot figure out the problem. The directory looks set properly here:

MacBook-Air:~ user$ java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

MacBook-Air:~ user$ echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

my bash_profile:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home M2_HOME=/usr/local/opt/maven/libexec
M2=/usr/local/opt/maven/libexec/bin PATH=/usr/local/opt/maven/libexec/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

john cs
  • 2,220
  • 5
  • 32
  • 50
  • Thats probably the first thread I found and if it had worked, we wouldn't be here right now – john cs Sep 20 '15 at 00:19
  • Start by making sure that `mvn` is the real thing, with `type mvn`. This should give you a path to a shell script. Take a look at that script, and verify that it hasn't been mucked with (compare to a fresh download). Assuming it's the same, look at the configuration files that it loads (`/etc/mavenrc` and `"$HOME/.mavenrc` on my machine). You could also try `echo $JAVA_HOME` inside this script. – kdgregory Sep 20 '15 at 00:34
  • 1
    Also, take a look at `$HOME/.bashrc` to see if it changes `JAVA_HOME`. Based on the error message, you're running Java 6, not 8, regardless of what happens from the command-line. There will be a reason somewhere in your exec chain. – kdgregory Sep 20 '15 at 00:35
  • You are trying to run a Java-8 compiled file in a Java-7 VM. – Mad Physicist Sep 20 '15 at 04:46

0 Answers0