Ubuntu下安装JDK

Posted on 2012-10-26 21:47  wang_sd01  阅读(180)  评论(0)    收藏  举报

 装JDK最好把原来的OpenJDK删除。

The link has instructions for installing Oracle JDK, the Java 7 browser plugin and how to revert the changes.

So here is a tested (under Ubuntu 11.04 and 11.10) and working solution for installing Oracle JDK 7 and all its files so "javac" and everything else works: How To Install Oracle Java 7 (JDK) In Ubuntu

Here are the commands (just for convenience):

  1. Download the latest Oracle JDK 7 from here.
  2. Extract the downloaded Oracle Java JDK archive in your home folder - a new folder called "jdk1.7.0_03" (for Java JDK7 update 3) should be created. Rename it to "java-7-oracle" and move it to /usr/lib/jvm using the following commands:
cd
sudo mkdir -p /usr/lib/jvm/      #just in case
sudo mv java-7-oracle/ /usr/lib/jvm/

3. Install Update Java package created by Bruce Ingalls (packages available for Ubuntu 11.10, 11.04, 10.10 and 10.04):

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java

4. Now run the following command in a terminal to install Oracle Java JDK:

sudo update-java

Select the Java Version that you want to install and set as the default

After a few minutes, Oracle Java JDK should be successfully installed on your Ubuntu machine. You can check out the version by running these commands in a terminal:

java -version
javac -version

博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3