在 Mac OS X 上安装了 Java 7 但终端仍在使用版本 6 [英] Installed Java 7 on Mac OS X but Terminal is still using version 6
问题描述
我已经安装了从 oracle 网站下载的 JDK 7u7.但是安装后终端还是显示java version 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 home 变量设置为 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 Preferences 窗格,您只需使用 ⌘+SPACE 并输入 System Preferences 它将显示在窗口的最后一行.
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屋!