打开命令行工具
which java
/usr/bin/java
ls -l /usr/bin/java
lrwxr-xr-x 1 root wheel 74 12 3 2015 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
ls -l /System/Library/Frameworks/JavaVM.framework/Versions
drwxr-xr-x 8 root wheel 272 12 3 2015 A
lrwxr-xr-x 1 root wheel 1 12 3 2015 Current -> A
java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
定位JAVA_HOME
/usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
cat ~/.profile
JAVA_HOME=`/usr/libexec/java_home`
export JAVA_HOME
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
/usr/libexec/java_home -V