您的位置:首页 > 编程语言 > Java开发

How to set the JAVA_HOME variable in Mac OS X – Snow Leopard

2010-08-05 09:14 731 查看
Recently I had to setup a Java app on my Mac, which was running from the Terminal, and needed the JAVA_HOME variable set.

Here’s what had to be done:

- Start the Terminal app.

- Create/Edit ~/.bash_profile file.

Note: I first tried creating and using the ~/.bashrc file, but that didn’t work (Mac OS 10.6.2), while ~/.bash_profile worked as expected.

Therefore,

$ vi ~/.bash_profile

… and paste the following (make it a single line):

export JAVA_HOME=/System/Library/Frameworks/

JavaVM.framework/Versions/CurrentJDK/Home


… save and exit vi.

Restart Terminal app just to be sure that it worked, and try accessing it by typing:

$ echo $JAVA_HOME

If you see the correct JAVA path, then it is all done!

我的电脑显示如下:

macbookpro:bin shang$ echo $JAVA_HOME

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐