Android L recommended using the JDK7 compiler, which is the natural evolution of the law, just like 4 years ago to compile Android 1.6 needs to use JDK5.
Multiple versions of the JDK can coexist, and you can switch them at any time using the Update-alternatives tool. The procedures for installing OPENJDK and Oracle JDK (Sun) and switching versions are described below.
First, install the OPENJDK7
$ sudo apt-get update$ sudo apt-get install OPENJDK-7-JDK
Locate the installation path after the installation is complete:
$ dpkg-l openjdk-7-jdk/./usr/usr/lib/usr/lib/jvm/usr/lib/jvm/java-7-openjdk-amd64$ ls/usr/lib/jvm/ Java-7-openjdk-amd64/assembly_exception bin docs include JRE lib man src.zip Third_party_readme
Second, switch Java version
$ sudo update-alternatives--config javathere is 2 choices for the alternative Java (Providing/usr/bin/java). Selection Path priority Status------------------------------------------------------------* 0 / Usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 Auto mode 1 /usr/lib/jvm/ Java-6-openjdk-amd64/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/ Bin/java 1051 manual modepress Enter to keep the current choice[*], or type selection Number:2update-alternativ Es:using/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java to Provide/usr/bin/java (Java) in manual mode.$ Java-versionja VA version "1.7.0_65" OpenJDK Runtime Environment (IcedTea 2.5.3) (7u71-2.5.3-0ubuntu0.12.04.1)
Third, install the Oracle JDK using Android Studio to do development, start the IDE prompt:
OpenJDK shows intermittent performance and UI issues. We recommend using the Oracle jre/jdk.
It appears that you want to install the Oracle JDK, because the Ubuntu software source does not have this JDK, so you cannot use the Apt-get tool as you would install OPENJDK.
Then we still have to go to the official website to download jdk7.
As usual, I put the software in the/OPT directory. Unzip the JDK to the new directory JDK.
Use the Update-alternatives tool to add Java optional configuration items (this is a dpkg utility).
$ sudo update-alternatives--install/usr/bin/java java/opt/jdk/jdk1.7.0_71/bin/java 700$ sudo update-alternatives-- Install/usr/bin/javac javac/opt/jdk/jdk1.7.0_71/bin/javac 700$ sudo update-alternatives--install/usr/bin/jar jar/ Opt/jdk/jdk1.7.0_71/bin/jar 700
700 is the priority value, I use a random number here.
Take a look at our config:
$ sudo update-alternatives--config javathere is 3 choices for the alternative Java (Providing/usr/bin/java). Selection Path priority Status------------------------------------------------------------ 0 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 Auto mode 1 /opt/jdk/jdk1.7.0_71/bin/ Java Manual mode 2 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 Manual mode* 3 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual modepress Enter to keep the current Choice[*], or type selection Number:1update-alternatives:using/opt/jdk/jdk1.7.0_71/bin/java to Provide/usr/bin/java ( java) in manual mode
Verify that the switch was successful:
$ Java-versionjava Version "1.7.0_71" Java (tm) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot (tm) 64-bit Server V M (build 24.71-b01, Mixed mode)
Similarly, when we need to switch to the lower version select 2 or install Oracle JDK6 and incorporate it into management. This allows you to flexibly switch the JDK version without having to manually modify the environment.
Android Combat Skill Eight: Switch jdk version under Ubuntu