Javac Java version switching

Source: Internet
Author: User

If there is more than one Java version installed (sometimes some software installed itself), how to easily switch it. In addition to the common settings environment variables, today learned a new way to switch:

Update-alternatives--config Java
Update-alternatives--config Javac

Also, how to install your own Java version:

sudo update-alternatives--install/usr/bin/java Java/opt/jdk1.7.0_67/bin/java 50
sudo update-alternatives--install/usr/bin/javac Javac/opt/jdk1.7.0_67/bin/javac 50
sudo update-alternatives--install/usr/bin/javah javah/opt/jdk1.7.0_67/bin/javah 50
sudo update-alternatives--install/usr/bin/javaws javaws/opt/jdk1.7.0_67/bin/javaws 50
sudo update-alternatives--install/usr/bin/javap JAVAP/OPT/JDK1.7.0_67/BIN/JAVAP 50

----------------------------------------another article----------------------------------------

Since you want to compile 2.1 and 2.3 two code in the same Ubuntu environment, and they are using a Java version of one is 1.5, one is 1.6, so you need to switch before compiling;

The switching method is simple, using the following two commands:

Update-alternatives--config Java
Update-alternatives--config Javac

For example:

[Email protected]:~# update-alternatives--config java
There is 2 choices for the alternative Java (Providing/usr/bin/java).

Select Path Priority state
------------------------------------------------------------
* 0/usr/lib/jvm/java-6-sun/jre/bin/java 63 Auto 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 ENTER, or type the number of your choice: 1
Update-alternatives: Use/usr/lib/jvm/java-1.5.0-sun/jre/bin/java to provide/usr/bin/java (Java) in manual mode.

Just enter the number you want to switch to enter, do not change the words directly enter, don't forget Javac also changed ~

After the change,

Java-version

Javac-version

Javac Java version switching

Related Article

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.