Monday, April 18, 2016

Where is Java home on Mac OS X?

I'm using Mac OS X Lion v10.7 and I have downloaded Java 8 DMG file from Oracle's web site and installed it. After installing it, i can't find Java home directory. According to http://stackoverflow.com/questions/1348842/what-should-i-set-java-home-to-on-osx, there is an executable file that print Java home location to console by default, /usr/libexec/java_home.

> ls -l /usr/libexec/java_home
lrwxr-xr-x  1 root  wheel  79 Apr  7 17:03 /usr/libexec/java_home -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
> /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

And then you can set JAVA_HOME variable in /etc/profile file as following:
> export JAVA_HOME=$(/usr/libexec/java_home)


No comments:

Post a Comment