Reputation: 9169
Beating my head on the wall with this. Using Mac 10.10 and my java -version works but mvn -version gives me
error: JAVA_HOME is not defined correctly. We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home/bin/java
and that's not even my correct jdk. Here is what my bash_profile looks like:export
export JAVA_HOME=/Library/Java/JavaVirtualMachine/jdk1.8.0_25.jdk/Contents/Home
export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.3
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m-Xmx512m
export PATH=$M2:$PATH
Upvotes: 1
Views: 1757
Reputation: 13
install maven in mac/linux (mac in your case), should following this http://maven.apache.org/download.cgi section:Unix-based Operating Systems (Linux, Solaris and Mac OS X)
if your default terminal is bash (echo $SHELL
will output something like: /bin/bash)
run echo $JAVA_HOME
first before run mvn.
isaacdong-imac:~ isaac$ echo $SHELL /bin/bash
isaacdong-imac:~ isaac$
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
isaacdong-imac:~ isaac$
if your JAVA_HOME is empty, please note this: export command ONLY current env of shell process. when you open a new shell or restart mac. export effect is gone.
see this: Set environment variables on Mac OS X Lion
Upvotes: 0
Reputation: 645
Please check the mvn.sh script, make sure you have not set the JAVA_HOME in it. Or redownload a maven package and unpack.
And check /etc/launchd.conf, have you set a JAVA_HOME in it?
Upvotes: 0
Reputation: 8338
That is (maybe) because iOS has a default Java installed and you have another Java VM that you downloaded yourself.
Try this, instead of defining the java home, let the OS use the one installed. In your profile, or on a shell script do this
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
Or whatever version of java you are using. For example, if you have java 6 and 7 installed, then running
export JAVA_HOME=`/usr/libexec/java_home -v 1.7`
will select java 7, whereas
export JAVA_HOME=`/usr/libexec/java_home -v 1.6`
will let you use Java 6.
NOTE the back ticks.
Upvotes: 0
Reputation: 108
When I ran into this. I needed to restart the Terminal app. For it to pick up the new bash_profile changes.
Upvotes: 1