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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With