Install multiple JDK versions under Linux __linux

Source: Internet
Author: User
Tags java se
Install multiple JDK versions under Linux

NOV 21ST, 2014 | COMMENTS

4.4 (KitKat) has been used before the SunJDK1.6 version of the original compiled, to 4.4, began to compile with the SunJDK1.7 version, from the Android L start to the current 5.0 Google started to use OPENJDK to compile. So on a computer to do the source code compilation needs to install multiple versions of the JDK.

The system I'm using now is LinuxMint17, based on Ubuntu 14.04.

Now you need to use a few versions of the JDK, so it's all installed and switched as needed. 1.sunjdk1.6

Jdk-6u43-linux-x64.bin can be downloaded here, the installation method can be seen in this Ubuntu configuration Java SE 1.6 2.sunjdk1.7

can go to sunjdk official website download JDK7, after downloading to perform the following command decompression:

TAR-ZVFX jdk-7u72-linux-x64.tar.gz
sudo mv-rf jdk1.7.0_72//opt/jdk1.7.0_72
3.openjdk7

You can install the following command directly on the terminal

sudo apt-get install OPENJDK-7-JDK

After installing the three JDK versions, restart the computer, and then do the following: 1. Check the Java installation First

sudo update-alternatives--display java
sudo update-alternatives--display javac

The results are shown below (I have configured them below)

1
2
3
4
5
6 7 8 9 (15)
apar@g470 ~ $ sudo update-alternatives--display java
-Manual mode
link currently points to/opt/jdk1.7.0_72/bin/java
/opt/ Jdk1.6.0_43/bin/java-Priority
/opt/jdk1.7.0_72/bin/java-priority
/usr/lib/jvm/java-7-openjdk-amd64/bin/ Java-priority
is currently the "best" version for/usr/lib/jvm/java-7-openjdk-amd64/bin/java.
apar@g470 ~ $ sudo update-alternatives--display javac
javac-Manual mode
link is currently pointing to/opt/jdk1.7.0_72/bin/javac
/opt/jdk1.6.0_43/bin/javac-Priority
/opt/jdk1.7.0_72/bin/javac-priority
/usr/lib/jvm/ Java-7-openjdk-amd64/bin/javac-Priority is the
current "best" version for/usr/lib/jvm/java-7-openjdk-amd64/bin/javac.
apar@g470 ~ $
2). Delete a symbolic link

Perform a command similar to the following to delete a signed link that already exists

sudo update-alternatives--remove java/opt/jdk1.6.0_43/bin/java
sudo update-alternatives--remove javac/opt/ Jdk1.6.0_43/bin/javac

Confirm that the symbolic links (symlinks) are deleted

Java-version
javac-version
3). Reconfigure Java links

Execute a command similar to the following

sudo update-alternatives--install/usr/bin/java java/opt/jdk1.6.0_43/bin/java-
sudo update-alternatives- Install/usr/bin/java Java/opt/jdk1.7.0_72/bin/java
sudo update-alternatives--install/usr/bin/java java/usr /lib/jvm/java-7-openjdk-amd64/bin/java

sudo update-alternatives--install/usr/bin/javac javac/opt/jdk1.6.0 _43/bin/javac
sudo update-alternatives--install/usr/bin/javac javac/opt/jdk1.7.0_72/bin/javac
sudo Update-alternatives--install/usr/bin/javac Javac/usr/lib/jvm/java-7-openjdk-amd64/bin/javac 500
4. Manual switching can be done when needed
sudo update-alternatives--config java
sudo update-alternatives--config javac

The results appear as follows:

1
2
3
4
5
6
7 8 9
24 (
est
)
apar@g470 ~ $ sudo update-alternatives--config java
[sudo] password for apar:
3 candidates are available to replace Java (provide/usr/bin/j Ava).

  Select the       path                                      priority  State
------------------------------------------------------------

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.