view raw
Hassan Syyid Hassan Syyid - 6 months ago 53
Java Question

Java 6 Unsupported major.minor version 51.0

I recently uninstalled Java 8, to use Java 6 as I want my code/creations to be usable by more people than just those on Java 8. When I do mvn - version it returns:

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(
at java.lang.ClassLoader.defineClass(
at Method)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
at org.codehaus.plexus.classworlds.launcher.Launcher.main(

When I do java -version:

java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Everything seems fine with Java, but this also happens when I try to run executable JARS. I got around it by manually doing java -jar (jar name)

Any help would be greatly appreciated!


According to maven website, the last version to support Java 6 is 3.2.5, and 3.3 and up use Java 7. My hunch is that you're using Maven 3.3 or higher, and should either upgrade to Java 7 (and set proper source/target attributes in your pom) or downgrade maven.