在MAC OSX 10.9上设置JAVA_HOME环境变量 [英] Setting JAVA_HOME environment variable on MAC OSX 10.9

查看:198
本文介绍了在MAC OSX 10.9上设置JAVA_HOME环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚买了一台全新的MacBook Pro。这是我有史以来的第一个MAC,我仍然试图掌握导航方式。无论如何......我也是Java的新手,我在Windows PC上练习,然后才永久死亡。现在我在这个MAC上,我安装了我的JDK,现在我需要设置 JAVA_HOME 环境变量。我不知道该怎么做。

I just purchased a brand new MacBook Pro. This is my first MAC ever and I'm still trying to get the hang of navigating my way around. Anyways... I'm also new to Java and I've been practicing on my Windows PC before it permanently died. Now that I'm on this MAC, I installed my JDK and now I need to set the JAVA_HOME environment variable. I have no idea what to do.

我尝试了一些这些指南并且没有走得太远。

I tried following some of these guides and didn't get very far.

http:/ /www.mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/
http://www.youtube.com/watch?v=aCEPrODy68o

我我非常肯定这个让我创建了一个现在无用的文件:

youtube.com/watch?v=-cASjkF94dc

And I'm very sure this one made me create a now useless file:
youtube.com/watch?v=-cASjkF94dc

我能够找到终端,我想我创建了一些多个文件。我收到这样的消息:

I was able to locate the terminal and I think I created some multiple files. I'm getting messages like this:


(1)另一个程序可能正在编辑同一档案。
如果是这种情况,请注意在进行更改时最终不得使用同一文件的两个
不同实例。
退出,或继续谨慎。

(1) Another program may be editing the same file. If this is the case, be careful not to end up with two different instances of the same file when making changes. Quit, or continue with caution.








(2)此文件的编辑会话崩溃。
如果是这种情况,请使用:recover或vim -r /Users/Erwin/.bash_profile
来恢复更改(请参阅:help recovery)。
如果您已经这样做,请删除交换文件/Users/Erwin/.bash_profile.sw p
以避免此消息。

(2) An edit session for this file crashed. If this is the case, use ":recover" or "vim -r /Users/Erwin/.bash_profile" to recover the changes (see ":help recovery"). If you did this already, delete the swap file "/Users/Erwin/.bash_profile.sw p" to avoid this message.

有些Mac专家可以帮助我解决这个问题并逐步设置Java环境吗?

Can some Mac expert out there help me in fixing this and setting Java environment step by step?

推荐答案

字面上你所要做的就是:

Literally all you have to do is:

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile

并重启你的shell。

and restart your shell.

如果您安装了多个JDK版本并且希望它是特定版本,则可以使用 -v 标志来 java_home 像这样:

If you have multiple JDK versions installed and you want it to be a specific one, you can use the -v flag to java_home like so:

echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile

这篇关于在MAC OSX 10.9上设置JAVA_HOME环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆