Maven Unsupported major.minor version 51.0

Maven - Unsupported Major Minor Version Error

If you are getting the below error message while working on Maven then make sure that the JAVA_HOME environment variable has been set correctly.

bash-3.2$ mvn --version

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 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(

Note this is for macOS running 10.10 Yosemite with JRE version 1.8

  1. Open Terminal,
  2. Run Command : echo $JAVA_HOME
  3. Check if the jre path set is correct : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/
  4. If not then use the following command to set it : export
  5. JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/
  6. Now to verify if the issue is resolved run command : mvn --version
bash-3.2$ mvn --version

Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /Users/c2c/Setups/apache-maven-3.3.3
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"

If everything worked fine you should get no error and get an output as above.

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap