javamavenspring-mvcunsupported-class-versionmaven-install-plugin

STS: run as -> maven install error


I'm using Spring Tool Suite (basically the same as Eclipse, can't actually find a difference but I'm being made to use it) for an assignment and I'm having an error when I right click on the project and click 'Run As -> Maven Install'.

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)

Everything else I have found on stack exchange implies that this is something to do with the Java Version, but I can't figure out how I have it wrong. When I run mvn -version on terminal I get

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T21:57:37+10:00)
Maven home: /usr/local/Cellar/maven/3.3.3/libexec
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.4", arch: "x86_64", family: "mac"

When I run java -version I get

java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

I tried setting JAVA_HOME (as per Maven Installation OSX Error Unsupported major.minor version 51.0) and it is set to the correct path.

My STS settings say it's compiling using 1.8, and running using 1.8, and the properties of the project say it's compiling using 1.8 too. I don't understand where the problem is.

I originally tried changing everything to Java 1.7 to see if that was the problem but it still didn't help. I changed it back to 1.8 in the end because that's what the rest of my group are using.

This is my first post so I can't post screenshots, they're at the link. https://i.sstatic.net/0WPV5.jpg


Solution

  • I fixed it by deleting Java SE 6 from the Installed JREs list in screenshot 1. Even though 8 was selected, it was still using 6 for some reason.