Java 6 Unsupported version of major.minor 51.0

I recently removed Java 8 to use Java 6, as I want more people to use my code / creations than just 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(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) 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) 

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 it also happens when I try to run executable JARs. I bypassed it manually using java -jar (jar name)

+48
java maven unsupported-class-version
Jul 13 '15 at 10:18
source share
6 answers

According to the maven website , the latest version for supporting Java 6 is 3.2.5, and 3.3 is using Java 7. My guess is that you are using Maven 3.3 or higher, and should either upgrade to Java 7 (and set the correct attributes source / target in your pom), or change maven.

+68
Jul 13 '15 at 10:24
source share

This version number (51.0) indicates that you are trying to run classes compiled for Java 7. You will need to recompile them for Java 6.

Please note, however, that some functions can no longer be compatible with Java 6, which is very old and is no longer supported by (publicly) Oracle.

+8
Jul 13 '15 at 10:22
source share

i also ran into a similar problem. I was able to solve this by setting JAVA_HOME to the environment variable on Windows. Setting JAVA_HOME in a batch file does not work in this case.

+2
Jan 03 '15 at 11:25
source share

I am facing the same problem and can be solved by adding the JAVA_HOME variable with an updated version of java in my Ubuntu machine (16.04). if you use "Apache Maven 3.3.9" you need to update JAVA_HOME with java7 or more

Step for this

1-sudo vim / etc / environment

2-JAVA_HOME = JAVA installation directory (MyCase- / opt / dev / jdk1.7.0_45 /)

3-Run echo $ JAVA_HOME will give the value JAVA_HOME

4-Now mvn -version will give the desired result

 Apache Maven 3.3.9 Maven home: /usr/share/maven Java version: 1.7.0_45, vendor: Oracle Corporation Java home: /opt/dev/jdk1.7.0_45/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-36-generic", arch: "amd64", family: "unix" 
0
Oct 25 '16 at 12:05
source share

The problem is that you did not specify the correct version of the JDK. You should use jdk 7 for main number 51. For example:

JAVA_HOME = / USR / Java / jdk1.7.0_79

0
Dec 20 '16 at 12:17
source share

I ran into the same problem. I am using jdk 1.8 and maven 3.3.9. As soon as I export JAVA_HOME, I did not see this error. export JAVA_HOME = / Library / Java / JavaVirtualMachines / jdk1.8.0_121.jdk / Contents / Home /

0
Apr 25 '17 at 15:22
source share



All Articles