1. Download the latest Oracle JDK 7 from HERE (you must click "accept license" and then download the .tar.gz package for your computer architecture - jdk-7-linux-i586.tar.gz or jdk-7-linux-x64.tar.gz; these filenames are just examples, they will change on future releases). You can use these instructions for older JDK versions too, but make sure you use the appropriate folder names, etc. 2. Extract the downloaded Oracle Java JDK archive in your home folder - a new folder called "jdk1.7.0" (for Java JDK7) should be created(自动解压生成了,不用新建) and we must move it to /usr/lib/jvm using the following commands:
cd '/home/lxj/Labs' #个人把下载到的文件放在/home/lxj/Labs文件夹里
sudo mkdir -p /usr/lib/jvm/ #just in case (这里新建一个 jvm 文件夹,这步可省略不做)
sudo mv jdk1.7.0/ /usr/lib/jvm/ #生成:/usr/lib/jvm/jdk1.7.0
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
If you don't want to add the WebUpd8 PPA, you can also manually download the script.The script may work with other Linux distributions, but it has only been tested on Ubuntu.
4. Now run the following command in a terminal to install Oracle Java JDK:
sudo update-java The script will ask you to select the Java version - select "jdk1.7.0" for Oracle Java JDK 7, click OK and wait for it to finish:
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
The version should be "1.7.0".