How should I set the JAVA_HOME environment variable on macOS? [duplicate]

匆匆过客 提交于 2019-11-30 02:45:50
ntalbs

I'm not sure why you are afraid to test, you can safely test this:

In your terminal session, input the following:

echo "export JAVA_HOME=`/usr/libexec/java_home`"

This will print the following line:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Copy the above and paste it into your terminal window, then press enter key. and execute java -version to see it work correctly. If everything is okay, you can attach the code into your .profile:

But adding this line directly is better idea because you don't have to update .profile when you upgrade JDK.

export JAVA_HOME=`/usr/libexec/java_home`

Please refer to the man page for the java_home tool. In short, it provides the appropriate path for JAVA_HOME for a normal installation on macOS

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