warcbase icon indicating copy to clipboard operation
warcbase copied to clipboard

Maven error

Open drjwbaker opened this issue 9 years ago • 17 comments

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

Mac, OS X El Capitan.

When doing anything with mvn in the Terminal I get the 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)

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

You need Java 7 installed (more info here)

anjackson avatar Jun 08 '16 09:06 anjackson

So I need 7 as well as 8?

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

Ah, no. The error is consistent with Java 6 being the active version. What do you get if you print the Java version? e.g.

$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

anjackson avatar Jun 08 '16 09:06 anjackson

java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

(though elsewhere it says I'm on Java 8 Update 91)

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

So, is the JAVA_HOME environment variable set?

echo $JAVA_HOME

Because that can override the system default.

If that's not set, then you should be able to change the system Java version via System Preferences.

anjackson avatar Jun 08 '16 09:06 anjackson

That does nothing.

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

(that is echo $JAVA_HOME)

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

Happy to help hack with it @drjwbaker while we're in the same room – but for example, my JAVA_HOME is

/Library/Java/JavaVirtualMachines/jdk1.8.0_74.jdk/Contents/Home

(And when I've had to say downgrade Java for earlier versions of Gephi, etc., I manually override it to point to one of the other two versions of Java I have in /Library/Java/JavaVirtualMachines/)

ianmilligan1 avatar Jun 08 '16 09:06 ianmilligan1

Thanks both! Don't mind hacking through these kind of problems but always good to flag them if they are generic.

drjwbaker avatar Jun 08 '16 09:06 drjwbaker

Yep, very very helpful. I will document this once you confirm that it works. 😀

ianmilligan1 avatar Jun 08 '16 09:06 ianmilligan1

Two options I can think of. First, there's a hard-coded hook to Java 6 in your PATH. See

echo $PATH

Second, that Java 6 is set as your system default, which you change via the Java tab of the Java Control Panel which you can get to via System Preferences on OS X.

anjackson avatar Jun 08 '16 09:06 anjackson

Right. Back on this. echo $PATH gives me: //anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/munki:/Library/Application Support/pinpoint/bin Can't see how to change to change my version of Java in the Java Control Panel.

drjwbaker avatar Jun 09 '16 12:06 drjwbaker

It's there I promise!

Failing that, you can set JAVA_HOME as shown here: http://stackoverflow.com/a/24657630

anjackson avatar Jun 09 '16 18:06 anjackson

It's under "Java Runtime Environment Settings", as noted here https://java.com/en/download/help/mac_controlpanel.xml - see second image on this page for what it should look like: http://stackoverflow.com/questions/14304996/java-7-jre-installed-but-not-enabled-on-osx-mountain-lion

anjackson avatar Jun 09 '16 18:06 anjackson

I'd found that. Won't let me change Java's though. I just see 1.8.0_91. Do I need to install a different version of Java then? (stops Macs et cetera!)

drjwbaker avatar Jun 10 '16 13:06 drjwbaker