Oracle Java (JVM/JDK)目前已经不再在Debian/Ubuntu软件源,Oracle已经停止JDL协议,只发布OpenJDK。当然,如果你确实需要Oracle Java,可以从官网下载。
下面是Ubuntu 安装Oracle Java JDK 7方法
目前,Oracle Java JDK 7 只发布开发者预览版。
#1,下载Oracle JDK 7
点击这里,选择接受协议,下载即可。
#2,解压下载文件
解压时,会创建新文件夹”jdk1.7.0″。我们移动该文件夹到/usr/lib/jvm :
cd
sudo mkdir -p /usr/lib/jvm/ #just in case
sudo mv jdk1.7.0/ /usr/lib/jvm/
#3,安装升级的的Java软件包(Ubuntu 10.04+):
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java
如果不想添加PPA,可以直接下载脚本文件
#4,打开终端,输入下面命令安装Oracle Java JDK:
sudo update-java脚本会询问你选择哪个Java版本,我们选择“Jdk1.7.0”
稍等一会,Java安装完毕,可使用下面命令查询java版本:
java -version
javac -version
安装Oracle Java 7 浏览器插件 与安装Oracle JDK 6。
Install Oracle Java 7 Browser pluginUpdate: in my test, the Oracle Java 7 browser plugin crashes Firefox and doesn’t load in Chrome and it seems I’m not the only one, so it would be a good idea noy to upgrade the browser plugin too (JDK 7 seems works ok). If you want to try it out anyway, see the installation instructions below. There are also instructions on reverting the changes at the end of the post.
Even though the steps below are for Firefox, the plugin will also be updated in Chrome (possibly other browsers too) as it looks under ~/.mozilla/plugins folder for plugins too.
Firstly, remove old Java plugin links using the commands below:
rm -f ~/.mozilla/plugins/libnpjp2.so ~/.mozilla/plugins/libjavaplugin_oji.so
sudo rm -f /usr/lib/firefox/plugins/libnpjp2.so /usr/lib/firefox/plugins/libjavaplugin_oji.so
And for the last step, let’s create a simbolic link for the newly installed Java into the Mozilla plugins directory:
– 32bit:
ln -s /usr/lib/jvm/jdk1.7.0/lib/i386/libnpjp2.so ~/.mozilla/plugins/
– 64bit:
ln -s /usr/lib/jvm/jdk1.7.0/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
Reverting the changes
Install Oracle JDK 6 from the Ubuntu repositories (make sure you enable the Partner repository under Ubuntu Software Center > Software Sources; alternatively, you can also use the LFFL Java PPA):
sudo apt-get install sun-java6-jdk sun-java6-plugin
Or, you can instal OpenDJK:
sudo apt-get install openjdk-6-jdk icedtea-plugin
Now run our script:
sudo update-java
And select the “java-6-sun-1.6.0.26” (“java-6-sun” works too) for Oracle JDK or the “java-1.6.0-openjdk” folder for OpenJDK.
For Oracle JDK, let’s revert the browser plugin changes too:
rm -f ~/.mozilla/plugins/libnpjp2.so
32bit:
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/
64bit:
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/