Java version switching in Ubuntu

Source: Internet
Author: User
In Ubuntu, if multiple Java versions are installed (sometimes some software is installed on its own), how can we conveniently switch between them. In addition to setting common environment variables, we learned a new switching method today: update-alternatives -- configjavaupdate-alternatives -- configjavac. In addition, how to install your java version: sudoupdate-alternatives -- instal

In Ubuntu, if multiple Java versions are installed (sometimes some software is installed on its own), how can we conveniently switch between them. In addition to setting environment variables, we have learned a new switching method today:

Update-alternatives -- config java
Update-alternatives -- config javac

In addition, how to install your java version:

Sudo update-alternatives -- install/usr/bin/java/opt/jdk1.7.0 _ 67/bin/java 50
Sudo update-alternatives -- install/usr/bin/javac/opt/jdk1.7.0 _ 67/bin/javac 50
Sudo update-alternatives -- install/usr/bin/javah/opt/jdk1.7.0 _ 67/bin/javah 50
Sudo update-alternatives -- install/usr/bin/javaws/opt/jdk1.7.0 _ 67/bin/javaws 50
Sudo update-alternatives -- install/usr/bin/javap/opt/jdk1.7.0 _ 67/bin/javap 50

---------------------------------------- Another article ----------------------------------------

To compile code 2.1 and code 2.3 in the same Ubuntu environment, and the java version they use is 1.5 and the java version is 1.6, you need to switch before compiling;

The switchover method is simple. Use the following two commands:

Update-alternatives -- config java
Update-alternatives -- config javac

For example:

Root@www.linuxidc.com :~ # Update-alternatives -- config java
There are 2 choices for the alternative java (providing/usr/bin/java ).

Select the path priority status
------------------------------------------------------------
* 0/usr/lib/jvm/java-6-sun/jre/bin/java 63 automatic mode
1/usr/lib/jvm/java-1.5.0-sun/jre/bin/java 53 manual mode
2/usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode

To maintain the current value [*], press the Enter key or enter the selected number: 1.
Update-alternatives:/usr/lib/jvm/java-1.5.0-sun/jre/bin/java is used to provide/usr/bin/java (java) in manual mode.

You only need to enter the desired number and press Enter. If you do not change the number, press enter directly. Do not forget to change the value of javac ~

After modification,

Java-version

Javac-version

Confirm ~

Multi-version JDK switch in UbuntuHttp://www.linuxidc.com/Linux/2014-07/104087.htm

Install JDK 7 (with Clojure download) http://www.linuxidc.com/Linux/2012-10/71557.htm under Ubuntu

Install JDK1.7 http://www.linuxidc.com/Linux/2012-06/62239.htm in Ubuntu 12.04

CentOS6.3 install JDK and environment configuration http://www.linuxidc.com/Linux/2012-09/70780.htm

Ubuntu 14.04 install JDK8 http://www.linuxidc.com/Linux/2014-09/106218.htm

Install JDK graph analysis http://www.linuxidc.com/Linux/2014-09/107291.htm under Ubuntu

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

This article permanently updates the link address: Http://www.linuxidc.com/Linux/2014-10/108074.htm

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.