I'm trying to build different version AOSP and android in ubuntu 14.04. However, I need to switch between different versions of OpenJDK and JAVA SE JDK.
I know I can use update-alternative
to deal with different installation. But, JAVA SE JDK doesn't appear in update-alternative
. It's just the contents of a tar ball.
Could anyone suggest a better to deal with different tools for building different targets?
You can add your JDK installation into update-alternative
manually.
How you can achieve that:
download JDK you need, e.g. jdk-6u45-linux-x64.bin
extract it; for example, chmod +x jdk-6u45-linux-x64.bin && ./jdk-6u45-linux-x64.bin
move it in the place you want; personally I prefer /opt
, so sudo mv jdk1.6.0_45 /opt
you can skip this step, but I'd recommend using symbolic links sudo ln -fs /opt/jdk1.6.0_45 /opt/jdk1.6
add manually this version sudo update-alternatives --install /usr/bin/java java /opt/jdk1.6/bin/java 1
Note: I'm using symbolic links there.
Then you can always change current JDK with
sudo update-alternatives --config java
.
And then you can check current version of Java being used in the system.
>java - version java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
More information you can find in manual page of update-alternatives
.