Switch multiple JDK environments under Ubuntu

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.