Use Update-alternatives to implement JDK selection during compilation on different Android platforms

Source: Internet
Author: User

Tian haili @ csdn

 

Different Android platforms use different JDK versions during compilation. For example, froyo (2.2) and its earlier versions require JDK; gingerbread and later versions require JDK. If you want to build different platform projects in an environment, you need to install different JDK. It takes time and effort to install JDK repeatedly during project switching. Update-alternatives provides a solution for this situation.

 

This article is just a supplement to the compilation of android2.2 platform under ubuntu10.10. It is the solution for the author to compile gingerbread.

 

1.3.2 Medium

1) download the official jdk6, the author download is jdk-6u30-linux-i586.bin

2) then execute the installation,

Haili @ haili-desktop :~ $ Cd ~

Haili @ haili-desktop :~ $ Chmod + x jdk-6u30-linux-i586.bin

Haili @ haili-desktop :~ $./Jdk-6u30-linux-i586.bin

After execution, generate ~ /Jdk1.6.0 _ 30

3) JDK version Switch

If multiple JDK versions are installed, you can use Update-alternatives to set the version and select which version to use.

First, an optional configuration option is generated for JDK:

Haili @ haili-desktop :~ $ Sudoupdate-alternatives -- install/usr/bin/JDK ~ /Jdk1.6.0 _ 30 254

Note:/usr/bin/JDK is a symbolic link pointing to/etc/alternatives/JDK (given by 2nd parameters);/etc/alternatives/JDK is a symbolic link, it points ~ /Jdk1.6.0 _ 30 .~ /Jdk1.6.0 _ 30 (/home/haili/jdk1.6.0 _ 30) is the actual target link, and 254 is the priority (any integer. in automatic mode, the priority of a large number is higher, is selected as the default configuration option ).

 

After performing the preceding operations, you can use Update-alternatives to switch to JDK.

 

You can use -- display to view the associations with/etc/alternatices/JDK:

Haili @ haili-desktop :~ $ Update-alternatives -- displayjdk

JDK-manual mode

Link currently points to/home/haili/jdk1.5.0 _ 22

/Home/haili/jdk1.5.0 _ 22-priority 255

/Home/haili/jdk1.6.0 _ 30-priority 254

 

You can use -- config to switch to different JDK versions.

Haili @ haili-desktop :~ $ Sudoupdate-alternatives -- config JDK

[Sudo] passwordfor haili:

There are 2 choices for the alternative JDK (providing/usr/bin/JDK ).

 

Selection path priority status

--------------------------------------------------------------------------

0/home/haili/jdk1.5.0 _ 22 255 Auto Mode

1/home/haili/jdk1.5.0 _ 22 255 manual mode

* 2/home/haili/jdk1.6.0 _ 30 254 manual mode

 

Press ENTER tokeep the current choice [*], or type selection Number:

You can select different JDK.

 

In environment settings, you only need to set/usr/bin/JDK to link to the JDK you selected with update-alternatives.

 

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.