Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvn command not working on mac OS X Yosemite

Tags:

java

macos

maven

I have performed all the necessary steps like the following after referring other Stack overflow threads and online resources for installing / configuring maven. Here is what I did :

export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9

export M2=$M2_HOME/bin

My Java Home variable is also, set, as shown below:

echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.8.0_60/Contents/Home

export PATH=$M2:$PATH  

Inspite of doing all of the above, when I run mvn --version, I get Error: JAVA_HOME is not defined correctly. We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_60/Contents/Home/bin/java.

PATH Output is as follows :

 echo $PATH
/usr/local/apache-maven/apache-maven-3.3.9/bin:/usr/local/apache-maven/apache-maven-3.2.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/MacGPG2/bin
like image 636
John Avatar asked Jan 02 '16 07:01

John


1 Answers

export PATH=$M2:$PATH should be export PATH=$M2/bin:$PATH or export PATH=$M2_HOME/bin:$PATH

Also JAVA_HOME should be something like this

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60

then

export PATH=$JAVA_HOME/bin:$PATH

That's all.

All in one

export M2_HOME=/usr/local/apache-maven/apache-maven-3.3.9
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_60
export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
like image 87
11thdimension Avatar answered Sep 28 '22 07:09

11thdimension