Maven Installation OSX Error Unsupported major.minor version 51.0 Maven Installation OSX Error Unsupported major.minor version 51.0 java java

Maven Installation OSX Error Unsupported major.minor version 51.0


The problem is because you haven't set JAVA_HOME in Mac properly. In order to do that, you should do set it like this:

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

In my case my JDK installation is jdk1.8.0_40, make sure you type yours.

Then you can use maven commands.

Regards!


Please rather try:

$JAVA_HOME/bin/java -version

Maven uses $JAVA_HOME for classpath resolution of JRE libs.To be sure to use a certain JDK, set it explicitly before compiling, for example:

export JAVA_HOME=/usr/java/jdk1.7.0_51

Isn't there a version < 1.7 and you're using Maven 3.3.1? In this case the reason is a new prerequisite: https://issues.apache.org/jira/browse/MNG-5780


A dynamic $HOME/.zshrc solution, if you're like me ie. Linux @ work; MBP/A @ home

if [[ $(uname) == "Darwin" ]]; then export OSX=1; fiif [[ $(uname) ==  "Linux" ]]; then export LINUX=1; fiif [[ -n $OSX ]]; then        export JAVA_HOME=$(/usr/libexec/java_home)else        export JAVA_HOME=/usr/lib/jvm/default-javafi