Search code examples
macosmaven

Error: JAVA_HOME is not defined correctly, when installing Maven on Mac


It is suppose to be easy, but I'm having great difficulty installing Maven on to my mac 10.11.4.

I have created M2_HOME and PATH for Maven, but when I type in mvn --version, the terminal tell me

/Users/justin/apache-maven-3.3.9/bin/mvn: line 53: uname: command not found
/Users/justin/apache-maven-3.3.9/bin/mvn: line 143: which: command not found
/Users/justin/apache-maven-3.3.9/bin/mvn: line 171: which: command not found
Error: JAVA_HOME is not defined correctly.
  We cannot execute 

Why is this happening?

enter image description here


Solution

  • You need JAVA_HOME to be defined, as covered in installation guide.

    Check out this answer for additional details for MacOS.