>java -version
Unable to find a $JAVA_HOME at “/usr”, continuing with system-provided Java
I tried setting the environment variable
JAVA_HOME=/usr
but the error remained when running java.I found the following solution here:
First, find out where java actually is:
>ls -l' `which java`
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
I noticed a command called java_home in that same directory. Running that command yields the correct java home directory.
>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
To correctly set the my JAVA_HOME environment variable in future, I added the following to my
~/.profile
export JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`
Restart terminal and enjoy.
No comments:
Post a Comment