0

I am new in MAC OS World. I have a new laptop. I've installed Java JDK from oracle web site. Java 8 is correctly installed. The command java -version works I install maven : 1. I've downloaded the maven tar.gz and extract it on the Users directory. I create the file .bash_profile with the content :

export M2_HOME=/Users/dgeorges/Tools/apache-maven-3.2.5
export PATH=$PATH:$M2_HOME/bin
  1. Then i ran mvn -version and i have the following error : Error: JAVA_HOME is not defined correctly. We cannot execute /usr/libexec/java_home/bin/java

How to see the java installed directory ? Why mac ox search on /usr/libexec/java_home/bin/java ?

Thanks

Pracede
  • 4,226
  • 16
  • 65
  • 110
  • `/usr/libexec/java_home` is a _command_ that tells you the right value to put in `JAVA_HOME`, not the Java home directory itself. – Ian Roberts Jan 31 '15 at 16:28

1 Answers1

1

While apple itself recommends to set the JAVA_HOME to: /usr/libexec/java_home it doesn't work for maven. You have to set it to $(/usr/libexec/java_home). This executes and returns the value of OSX's current Java home dir.

So to do that, you have to update your JAVA_HOME. So, open the Terminal and type the following into it:

$ vim .bash_profile 

export JAVA_HOME=$(/usr/libexec/java_home)

$ source .bash_profile

Now maven should recognize your Java-version.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Christian
  • 22,585
  • 9
  • 80
  • 106