First install sun1.6, here I install the directory is/usr/java/jdk1.6.0_45
Then set the profile file/etc/profile (add the file at the end of the file)
sudo vim/etc/profile
Export java_home=/usr/java/jdk1.6.0_45
export jre_home=/usr/java/jdk1.6.0_45/jre
export classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
export path= $PATH: $JAVA _home/bin
Source/etc/profile
Then install openjdk1.7, you can install it in Software Center, and then execute the following command after installation:
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/java java/usr/java/jdk1.6.0_45/bin/java
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javac javac/usr/java/jdk1.6.0_45/bin/javac
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javadoc javadoc/usr/java/jdk1.6.0_45/bin/javadoc
gsc@gsc-250:~$ sudo update-alternatives--install/usr/bin/javap javap/usr/java/jdk1.6.0_45/bin/javap 300
Switch using the following command:
gsc@gsc-250:~/my_carreer/webrtc-checkout$ sudo update-alternatives--config java
There are 2 choices for the Alternative Java (Providing/usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Auto mode
1 /usr/java/jdk1.6.0 _45/bin/java Manual Mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 Manual Mode
Press ENTER to keep the present choice[*], or type selection number:
View current Java version:
<pre name= "code" class= "html ">gsc@gsc-250:~/my_carreer/webrtc-checkout$ java-version
java Version" 1.7.0_85 "
OpenJDK Runtime Environment (IcedTea 2.6.1) (7u85-2.6.1-5ubuntu0.14.04.1)
OpenJDK 64-bit Server VM (build 24.85-b03, Mixed mode)
The specific tools to switch are as follows:
2045 sudo update-alternatives--config java
2046 sudo update-alternatives --config javac 2047 sudo update-alternatives--config javadoc
2048 sudo update-alternatives--config javap