Set JavaJDK1.5 and 1.6 to coexist on Ubuntu

Source: Internet
Author: User
Because I develop Android on Ubuntu, I sometimes need to compile the sdk source code and use 1 normally. 6. You can use 1.5 to compile the doc document. Here we will list the miserable experiences and solutions of today's day for your reference! Haha! First of all, install jdk1.6, I am installed through sudoapt-getinstall this method, you can refer to the http://www.linuxidc.com/Linux/2009-03/186

Because I develop Android on Ubuntu, I sometimes need to compile the sdk source code and use 1 normally. 6. You can use 1.5 to compile the doc document. Here we will list the miserable experiences and solutions of today's day for your reference! Haha!

First of all, install jdk1.6, I am installed through sudo apt-get install in this way, you can refer to the http://www.linuxidc.com/Linux/2009-03/18699.htm and http://www.linuxidc.com/Linux/2011-02/32170.htm!

Later, JDK 1.5 was installed. After the installation was completed, environment variables were configured. The writer did not elaborate here. The following is the question.

Run on the terminal after installing 1.5Java-versionCommand to obtain the following content:

Linuxidc@www.linuxidc.com :~ $ Java-version
Java version "1.6.0 _ 24"
Java (TM) SE Runtime Environment (build 1.6.0 _ 24-b07)
Java HotSpot (TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

This shows that we are still using jdk1.6. How can we convert the jdk version to 1.5 by using commands? Enter the following command here:

Linuxidc@www.linuxidc.com :~ $Sudo update-alternatives -- config java

Get the following content:

Linuxidc@www.linuxidc.com :~ $ Sudo update-alternatives -- config java
One option can be used to replace item java (/usr/bin/java is provided ).

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

Note: currently, only JDK 1.6 is available in the java alternative. Therefore, to add another java alternative, JDK, run the following command:

Linuxidc@www.linuxidc.com :~ $Sudo update-alternatives -- install/usr/bin/java/home/wjl/devtool/jdk1.5/bin/java 255

Here,/usr/bin/java does not need to be changed, as your original jdk path,/Home/wjl/devtool/jdk1.5/bin/javaThis is the java path 255 of JDK as the priority.


Finally, check which java groups can replace each other. Run the following command:Update-alternatives -- config java

The following result is displayed:

Linuxidc@www.linuxidc.com :~ $ Update-alternatives -- config java
There are two options to replace item java (/usr/bin/java is provided ).

Select the path priority status
------------------------------------------------------------
0/home/wjl/devtool/jdk1.5/bin/java 255 automatic mode
1/home/wjl/devtool/jdk1.5/bin/java 255 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:

Select 1 or 2, and press enter to switch to the jdk version you need ~!!! So far, the settings have been successfully set. You can start compiling the android source code !!!

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.