确保正确设置JAVA_HOME [英] Making sure JAVA_HOME is correctly set
问题描述
对Java和Mac都很新......我想确保JAVA_HOME设置在其他程序中,我可以使用它的路径。
所以我做了一些谷歌搜索,这是我得到的:
Pretty new to Java and also to Mac ... I want to make sure JAVA_HOME is set so in other programs I can use its path. So I did some Googling and here is what I got:
如果我在终端I输入 / usr / libexec / java_home 得到这个:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
但如果我输入 echo $ JAVA_HOME 在终端,我什么都没收到。
If I enter /usr/libexec/java_home in terminal I get this: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home but if I enter echo $JAVA_HOME in terminal, I don't get anything back.
你能告诉我这里发生了什么吗?
Can you please tell me what is going on in here?
谢谢。
推荐答案
OSX上默认情况下未设置JAVA_HOME。您可以通过打开终端并执行以下命令来解决此问题:
JAVA_HOME isn't set by default on OSX. You can resolve this by opening terminal and executing the following:
echo "export JAVA_HOME=`/usr/libexec/java_home`" >> ~/.profile
. ~/.profile
这将导致JAVA_HOME在启动时设置(而不仅仅是当前会话) ,并立即添加它。
This will cause JAVA_HOME to be set on startup (rather than just the current session), and immediately add it.
这篇关于确保正确设置JAVA_HOME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!