在OSX小牛中设置Java Home环境变量 [英] Setting Java home enviroment variable in OSX Mavericks

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

问题描述

我有Java路径问题。



我已经安装了最新版本的Java 1.7.0_51。当我打开Java控制面板时,它告诉我您的系统具有推荐的Java版本。





但是,当我去终端并键入 java -version 我得到

  java版本1.6.0_32

所以搜索后我遇到了这个 SO Question ,告诉我我的Java家庭环境变量需要被设置。



然后我打开了bash_profile文件,并将以下行添加到文件顶部,位于我的Python路径信息上方。

  export JAVA_HOME =`/ usr / libexec / java_home -v 1.7.0_51` 


#设置Python的PATH 2.7
#原始版本保存在.bash_profile.pysave
PATH =/ Library / Frameworks / Python.framework / Versions / 2.7 / bin:$ {PATH}
export PATH

注意:我尝试过这两个 -v 1.7.0_51 -v 1.7



我在终端中保存文件并重新检查,仍然显示

  java版本1.6.0_32

当我重新启动终端我看到

 上次登录时间:Wed Feb 19 23:32:19 on ttys000 
无法找到匹配版本1.7的任何JVM。
localhost:/ user $

注意:无法找到匹配版本的任何JVM 1.7。



所以它试图寻找我的1.7,但只是找不到它。



我做错了什么?

解决方案

好的,我认为这一定是我的具体。如上所述,Java控制面板正在说Java 7已经安装。另外当我尝试

  / Library / Internet\ Plug-ins / JavaAppletPlugin.plugin / Contents / Home / bin / java  - 版本

我会得到

  java版本1.7.0_51
Java(TM)SE运行时环境(build 1.7.0_51-b13)

但是没有什么方法我安装了 JDK 它不会工作。它似乎没有出现在我机器上的任何地方。我仍然不知道为什么,但卸载(通过简单地删除1.6文件夹)现有的Java 6从我的机器,并再次安装Java 7 JDK最终修复它。



请给上述@ diaz994的票数。


I am having issues with my Java path.

I have installed the latest version of Java 1.7.0_51. When I open the Java control panel it tells me "Your system has the recommended version of Java."

However when I go to terminal and type java -version I get

java version "1.6.0_32"

So after searching around I came across this SO Question which tells me that my Java home environment variable needs to be set.

I then opened the bash_profile file and added the below line to the top of the file, above my Python path info.

export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_51`


# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

NOTE: I have tried this with both -v 1.7.0_51 and -v 1.7

I save the file and recheck in terminal but it is still showing

java version "1.6.0_32" 

when I restart Terminal I do however see

Last login: Wed Feb 19 23:32:19 on ttys000
Unable to find any JVMs matching version "1.7".
localhost:/ user$

Note: Unable to find any JVMs matching version "1.7".

So it is trying to look for my 1.7, but just not finding it.

What am I doing wrong?

解决方案

Ok, I think this must be specific to me. As above the Java control panel was saying that java 7 was installed. Also when i tried

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

I would get

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)

But no mater what way I installed the JDK it would not work. It just didn't seem to appear anywhere on my machine. I still don't know why, but uninstalling (by simply deleting the 1.6 folder) the existing Java 6 from my machine and once again installing Java 7 JDK eventually fixed it.

Please give the up-votes to @diaz994 above.

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

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