When you install Ubuntu, openjdk_1.7 is installed by default.
$ java-version
Java Version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.12.04.1)
OpenJDK 64-bit Server VM (build 24.79-b02, Mixed mode)
Now you need to install jdk_1.6
Installed in/opt/java/jdk1.6.0_45
/opt/java/jdk1.6.0_45# ls
Bin db JRE LICENSE readme.html THIRDPARTYLICENSEREADME.txt
COPYRIGHT include Lib man src.zip
Plus environment variables
User environment variable: add row in ~/.BASHRC
Export java_home=/opt/java/jdk1.6.0_45
Export Jre_home= $JAVA _home/jre
Export classpath=.: $JAVA _home/lib/dt.jar: $JRE _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export use_ccache=1
System Environment Variables: Add rows in/etc/profile
Export java_home=/opt/java/jdk1.6.0_45
Export Jre_home= $JAVA _home/jre
Export classpath=.: $JAVA _home/lib/dt.jar: $JRE _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin: $JRE _home/bin
Export use_ccache=1
Switching software versions via update-alternatives
Add jdk_1.6 to the command connector and use the--install option
$ sudo update-alternatives--install/usr/bin/java Java/opt/java/jdk1.6.0_45/bin/java 1062
If you want to remove, the--remove option
$ sudo update-alternatives --remove /usr/bin/java Java/opt/java/jdk1.6.0_45/bin/java 1062
Create a default command link--config
$ sudo update-alternatives--config java
There is 2 choices for the alternative Java (Providing/usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------------------------------
* 0/opt/java/jdk1.6.0_45/bin/java 1062 Auto mode
1/opt/java/jdk1.6.0_45/bin/java 1062 Manual Mode
2/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 Manual Mode
Press ENTER to keep the current choice[*], or type selection number:0
Similarly, Python can also switch
This article is from the "M-tier" blog, so be sure to keep this source http://mengix.blog.51cto.com/7194660/1860961
Switch multiple JDK environments under Ubuntu