Michaël Kees
Michaël Kees

Reputation: 23

Unsupported major.minor version 51.0 (org/apache/maven/cli/MavenCli) - MAC OS X

This is my java version: 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)

And my bash_profile:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
M2_HOME=/Users/michaelkees/apache-maven-3.3.9
M2=/Users/michaelkees/apache-maven-3.3.9/bin
PATH=/Users/michaelkees/apache-maven-3.3.9/bin:/Users/michaelkees/Documents/apache-maven-3.3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/sbin

When I try to use the command : 'mvn -v'

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0

Upvotes: 2

Views: 12106

Answers (2)

Nirbhay Rana
Nirbhay Rana

Reputation: 4357

Go to Run configuration and choose Java 7 or Java 8 for maven version above then 3.2.X Maven 3.3 required higher Java version.

Upvotes: 1

khmarbaise
khmarbaise

Reputation: 97517

Is you output of your .bash_profile what you have posted? If so than you need to change it cause the environment variables will not made available to sub processes. You need to use the following in your .bash_profile:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
export PATH=/Users/michaelkees/apache-maven-3.3.9/bin:$PATH

After you have changed it you need to make a new login.

An other approach is to define JAVA_HOME´ via.mavenrc` file which might be a little bit more flexible.

You need to create a file .mavenrc in your home directory $HOME/.mavenrc which contains a line like this:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home

Than you don't need to define JAVA_HOME in your .bash_profile.

Upvotes: 0

Related Questions