Multi-version JDK switch in Ubuntu

Source: Internet
Author: User

Multi-version JDK switch in Ubuntu

JDK recommended for different Android versions may be different. As a result, jdk of different versions is required for multiple Android versions.
Android L and the latest Google recommended openjdk-7-jdk, and restrictions can only use JDK 7 or later versions, but in versions 4.4 and below, JDK 7 Compilation failed, many project compilation failed, in addition to fixing compilation failure, we can also install JDK 6.
First, we download the sun-jdk-6, install a little, I release the file to the/opt/jdk directory
The configuration is as follows:
$ Sudo vim/etc/profile
Add the following content at the end of the file to save and close the file.

# for java
export JAVA_HOME=/opt/jdk
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=$PATH:${JAVA_HOME}/bin:${JRE_HOME}/bin

$ Source/etc/profile
* If you do not have a multi-version jdk, you can write the last line like this./opt/jdk will be used directly without switching.
PATH =$ {JAVA_HOME}/bin :$ {JRE_HOME}/bin: $ PATH

* If you have multiple jdks, you can write them in one line./usr/bin/java->/etc/alternatives/java
Export PATH = $ PATH :$ {JAVA_HOME}/bin :$ {JRE_HOME}/bin
Then execute the following
$ Sudo update-alternatives-install/usr/bin/javah/opt/jdk/bin/javah 255
$ Sudo update-alternatives-install/usr/bin/javac/opt/jdk/bin/javac 255
$ Sudo update-alternatives-install/usr/bin/java/opt/jdk/bin/java 255
$ Sudo update-alternatives-install/usr/bin/jar/opt/jdk/bin/jar 255

After installing sun jdk, We will install openjdk (install Ubuntu 14.04)
$ Sudo apt-get install openjdk-7-jdk
After the installation is complete, run the following command to switch your jdk
$ Sudo update-alternatives-config java
$ Sudo update-alternatives-config javac
$ Sudo update-alternatives-config javah
$ Sudo update-alternatives-config jar

Of course, you can set different jdk switches in the build when compiling different android versions.

Install JDK 7 In Ubuntu (with Clojure download)

Install JDK 12.04 in Ubuntu

CentOS6.3 install JDK and environment Configuration

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.