Tuesday, June 19, 2012

Your version is: java version "1.6.0_20". The correct version is: Java SE 1.6.

I cam across this issue with java while building Android source.

$ java -version < the output would be as below >
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.10.3)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

To install new version of java, Follow the below steps which worked for me.

Step1:

     Append the below lines to sources.list at /etc/apt/ as a sudo user.
deb http://ppa.launchpad.net/sun-java-community-team/sun-java6/ubuntu maverick main 
deb-src http://ppa.launchpad.net/sun-java-community-team/sun-java6/ubuntu maverick main
$ sudo gedit /etc/apt/sources.list

Step2:

     Do the following installations and updates.
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:sun-java-community-team/sun-java6
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

Step3:

     After the installations are done, you need to update your java version with the following command.
$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      auto mode
  1            /usr/lib/jvm/java-6-openjdk/jre/bin/java   1061      manual mode
  2            /usr/lib/jvm/java-6-sun/jre/bin/java       63        manual mode

Press enter to keep the current choice[*], or type selection number: 

Selection option 2 for selecting the right version of Java. 

Step4:

Now check your latest config and this should be as below.
$ java -version < the output would be as below >
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) 64-Bit Server VM (build 17.0-b16, mixed mode)


No comments:

Post a Comment