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

荒凉一梦 提交于 2020-03-28 03:15:43

参看: 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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!