Installing openjdk 6 and 7 on Ubuntu

I recently set up Ubuntu Server Desktop (Which is called Unity 3D(2D)), and eclipse for java web development and Android development.

However, some projects have build configuration based on jre 1.6.

Ubuntu 12.04 server’s default installed jre is 1.7.

So, I had to figure it out how to install jre 1.6 and 1.7

1. First off, let’s figure out which java version is installed, and set up as default.

java -version

2. Knowning Java Executable file Path

which java

3. Install openjdk-6-jdk

sudo apt-get install openjdk-6-jdk

4. Knowing where jre1.6 is installed.

update-alternatives --config 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/local/java/jre1.7.0_05/bin/java 1 manual mode

5. Setup Path in eclipse using that path. like