MAC OS X10下 JAVA的环境变量设置

参看: http://www.baeldung.com/java-home-on-windows-7-8-10-mac-os-x-linux

 

From OS X 10.5, Apple introduced a command line tool (/usr/libexec/java_home) which dynamically finds the top Java version specified in Java Preferences for the current user.

Open ~/.bash_profile in any text editor and add:

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

Save and close the file.

Open a Terminal and run the source command to apply the changes:

1
source ~/.bash_profile

Now we can check the value of the JAVA_HOME variable:

1
echo $JAVA_HOME

The result should be the path to the JDK installation:

1
/Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home
posted @ 2017-11-15 02:13  carol_wei  阅读(177)  评论(0编辑  收藏  举报