Why is java not recognized after Oracle JDK 7 is installed in Mac OS Lion [closed]

ぃ、小莉子 提交于 2020-01-05 03:44:09

问题


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.

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.

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.

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?


回答1:


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

Open a terminal on her Mac and run this.

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

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

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 ~ 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.

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



来源:https://stackoverflow.com/questions/16824367/why-is-java-not-recognized-after-oracle-jdk-7-is-installed-in-mac-os-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!