Ubuntu14 install jdk1.7

  
        

1. Go to Sun's official website to download

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

Select accept license and select JDK download for your model.

2, unzip the file, modify the file name

## first enter the administrator privileges $ sudo -i## then create a directory, extract the file $ mkdir /usr/lib/jvm$ tar zxvf Jdk-7u65-linux-i586.tar.gz -C /usr/lib/jvm$ cd /usr/lib/jvm## The following command is used to create a soft connection $ ln -s /usr/lib/jvm/jdk1. 7.0_65 /usr/lib/jvm/jdk1.7 

3. Add the environment variable at the end of the bashrc configuration file

$ vim ~/.bashrc

Add the following content

 Export JAVA_HOME=/usr/lib/jvm/jdk1.7export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$ PATH 

4, configure the default JDK version

update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7/bin/java 300 update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7/bin/javac 300 update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7/bin/jar 300 Update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7/bin/javah 300 update-alter Natives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7/bin/javap 300 

Then execute

update-alternatives --config javaupdate-alternatives --config javacupdate -alternatives

If you are installing the JDK for the first time, you will be prompted

There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java/bin/java Configuration. 

If it is not a first time installation, there will be different versions of the JDK option.

5, Test

$ java -versionjava version "1.7.0_21"Java(TM) SE Runtime Environment (build 1.7.0_65-b17)Java HotSpot(TM) Server VM (build 24.15-b04, mixed mode)
Copyright © Windows knowledge All Rights Reserved