我已经安装了从oracle网站下载的JDK 7u7。但是安装完成后,终端仍然显示java版本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没有出现吗?
答:
好的,问题已经解决了。以下是答案:
我发现我的终端有一个.bash_profile, java主变量被设置为1.6
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"
所以这就是每次我打开新终端窗口时导致问题的行。
只要去掉这条线就能解决问题。您仍然需要遵循@aleroot所说的,但如果这对您不起作用,请检查.bash_profile(或.bashrc)设置文件,以查看您之前是否导出过任何java版本。
基本问题:/usr/bin/java最初指向OSX自己提供的(/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java)
我们需要将它指向JDK安装程序下载的那个。以下步骤适用于OSX 10.10.4 Yosemite。
Open System Preferences -> select Java. The Java window opens.
Click on Java tab at the top. Click on 'View' button.
The Java Runtime Environment Settings tab opens as below:
Double click on the Path item and copy the path (cmd+c). This is the latest one installed by the JDK installer/updater. In my case, the path was /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Open terminal. In this step, we are going to point (symbolic link, ln -s command) the system java binary to the latest one, which we discovered in the previous step. Run the below command:
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin。插件/内容/ Home / bin / java /usr/bin/java
这是它。要验证,只需运行
java - version
在终端上。它应该输出您安装/更新到的最新版本。
基本问题:/usr/bin/java最初指向OSX自己提供的(/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java)
我们需要将它指向JDK安装程序下载的那个。以下步骤适用于OSX 10.10.4 Yosemite。
Open System Preferences -> select Java. The Java window opens.
Click on Java tab at the top. Click on 'View' button.
The Java Runtime Environment Settings tab opens as below:
Double click on the Path item and copy the path (cmd+c). This is the latest one installed by the JDK installer/updater. In my case, the path was /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
Open terminal. In this step, we are going to point (symbolic link, ln -s command) the system java binary to the latest one, which we discovered in the previous step. Run the below command:
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin。插件/内容/ Home / bin / java /usr/bin/java
这是它。要验证,只需运行
java - version
在终端上。它应该输出您安装/更新到的最新版本。
因为我还没有面对过这个问题,我有一种预感——
你能试试这个吗:
软链接“java_home”指向哪里:
ls -lrt /usr/libexec/java_home
输出:(发育不良)
lrwxr-xr-x java_home -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home . zip
**ls -lrt /System/Library/Frameworks/JavaVM.framework/Versions
我的MAC产生以下:
lrwxr-xr-x CurrentJDK ->
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents**
lrwxr-xr-x Current -> A
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.6.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 Oct 18 14:39 1.4 -> CurrentJDK
基于此,我们可能会得到进一步进行的提示?