Install Oracle JDK 6 in Linux for Android compilation

Latest distribution of Linux doesn't "officially" support the Oracle JDK 6 package anymore in their repositories. However product like Android still require this package for allow compilation. This mean we need to manually download and install it. The procedure is quite simple but need some steps to follow.

NOTE: This procedure is tested in Ubuntu distribution, don't know if is the same for other distributions...

First you need to manually download the JDK package from Oracle web site here.

Based to your system (32 or 64 bit) download the correct package. When I'm writing this post the current version is jdk-6u39-linux-i586.bin for 32 bit system and jdk-6u39-linux-x64.bin for 64 bit. Once download finished we need to unpack the content by typing the following commands (all the commands will be based to the 32 bit version revision 39 as example):

chmod +x jdk-6u39-linux-i586.bin

This will run the uncompressing procedure and, at the end, we have a new folder containing all the JDK files (that should be named as jdk1.6.0_39). Now we need to move this folder to the right path:

sudo chown root. -R jdk1.6.0_39/
sudo mv jdk1.6.0_39/ /usr/lib/jvm/

The first command assign this foder to root owner and the second move it.Now you have the Oracle JDK "installed" but you still can not use them since we need to configure the correct path for allow compiler to find the java files. This operation can be done by typing the following commands:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_39/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_39/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_39/bin/javaws" 1

sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

The procedure is 99% done. As finally we need only to check if JAVA_HOME variable is set and, in case, update it to point the JDK folder just installed.


Popular posts from this blog

Access GPIO from Linux user space

Launch an app from Android shell terminal

Qt 5 and " Failed to load platform plugin 'windows' " error