在Mac OS X上安装了Java 7,但终端仍在使用版本6 [英] Installed Java 7 on Mac OS X but Terminal is still using version 6
问题描述
我安装了从oracle网站下载的JDK 7u7。但安装后,终端仍显示java版本6
I've installed JDK 7u7 downloaded from oracle's website. But after installation, the terminal is still showing java version 6
$java -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10-428-11M3811)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01-428, mixed mode)
任何想法为什么java 7没有出现?
any idea why java 7 is not showing up?
答案:
好的,问题已经解决了。答案如下:
我发现我的终端有一个.bash_profile,java主变量设置为1.6
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"
因此,这是每次打开新终端窗口时导致问题的行。
只需删除此行即可解决问题。您仍然需要遵循@aleroot所说的内容,但如果这对您不起作用,请检查.bash_profile(或.bashrc)设置文件以查看您之前是否已导出任何Java版本。
So this is the line causing the problem every time I opened a new terminal window. Simply remove this line will solve the problem. You still need to follow what @aleroot said, but if that doesn't work for you, check the .bash_profile (or .bashrc) setting file to see if you've previously exported any java version.
推荐答案
因为您需要输入Java Preferences窗格并以这种方式仅标记JVM 7:
Because you need to enter in Java Preferences pane and flag only the JVM 7 in this way :
轻松快速地打开在Mac OS X中的 Java首选项窗格中,您只需使用⌘ + SPACE 调用聚光灯并输入系统偏好设置它将显示在窗口的最后一行。
To easily and quickly open the Java Preferences pane in Mac OS X you can simply call spotlight with ⌘+SPACE and type System Preferences it will show up in the last row of the window.
这篇关于在Mac OS X上安装了Java 7,但终端仍在使用版本6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!