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