为什么在Mac OS Lion中安装Oracle JDK 7后无法识别Java [英] Why is java not recognized after Oracle JDK 7 is installed in Mac OS Lion

查看:129
本文介绍了为什么在Mac OS Lion中安装Oracle JDK 7后无法识别Java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Mac OS X Lion 10.8.3 MacBook上安装了Oracle JDK 7 u21(64位). javac -version和java -version都在我的机器上返回正确的信息.

I have installed Oracle JDK 7 u21 (64bit) on my Mac OS X Lion 10.8.3 MacBook. Both javac -version and java -version return the correct information on my machine.

现在,根据我的安装说明,我的朋友将其安装在她的计算机上. [注意:我有为此目的而制作的详细安装文档.] 以前,该机器上装有Apple JDK 6.

Now, based on my installation instructions, my friend installed it on her machine. [Note:I have a detailed installation document that I made for this purpose.] Previously the machine had Apple JDK 6 on it.

但是,安装后,她报告了一个问题. 当她输入sudo javac -version时,将返回正确的javac版本. 但是当她尝试sudo java -version 她得到一个错误,告诉她Java是它无法识别的命令. 昨天我花了几个小时,试图通过Skype会话解决此问题,但无济于事.

However after the installation, she reports a problem. When she types in sudo javac -version, she gets returned the correct javac version. However when she tries sudo java -version she gets an error, telling her that java is a command that it does not recognize. I spent a couple of hours yesterday, trying to get this problem fixed on her machine through a Skype session, but to no avail.

因此,此问题的目的是找出:在此安装和配置中她可能会缺少什么?如果在具有相同版本的Mac OS和相同的Oracle JDK安装程序的计算机上使用相同的指令,在她的计算机上可能出了什么问题?

So the purpose of this question is to find out: what could she be missing in this installation and configuration? What could be going wrong on her machine with the same instructions that worked on my machine that has an identical version of Mac OS and the same Oracle JDK installer?

推荐答案

您可以尝试检查Java插件是否已安装.

You could try to check if the java plugin is installed.

在Mac上打开终端并运行它.

Open a terminal on her Mac and run this.

/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/bin/java -version

/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/bin/java -version

根据您的版本号,目录jdk1.7.0_10.jdk可能有所不同.

The directory jdk1.7.0_10.jdk might be different depending on your version number.

我相信这是Oracle设置JDK的途径.如果您找不到错误的地方.如果找到它,则应该可以通过终端编辑〜.bash_profile来将/Library/Java/JavaVirtualMachines/jdk(此处版本号)/Contents/Home/bin/添加到您的路径中.您可以这样做:

This is the path where Oracle sets up the JDK I believe. If you cannot find that something is wrong. If you do find it you should be able to add /Library/Java/JavaVirtualMachines/jdk(VERSION NUMBER HERE)/Contents/Home/bin/ to your path by editing ~.bash_profile via terminal. You can do that like this:

cd〜 纳米.bash_profile (在文件底部输入这样的信息):export PATH = $ PATH:/Library/Java/JavaVirtualMachines/jdk(VERSION NUMBER HERE)/Contents/Home/bin/ ctrl + o保存. Ctrl + x退出.

cd ~ nano .bash_profile (Enter the info like this at the bottom of the file): export PATH=$PATH:/Library/Java/JavaVirtualMachines/jdk(VERSION NUMBER HERE)/Contents/Home/bin/ ctrl+o to save. ctrl+x to exit.

然后关闭您的终端,然后重新打开.再次尝试该Java命令.

Then close your terminal and re-open it. Try that java command again.

这篇关于为什么在Mac OS Lion中安装Oracle JDK 7后无法识别Java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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