Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Wednesday, July 8, 2009

Changing default Java in Ubuntu

Just perform these steps to change the default Java in Ubuntu. I have been using the absolute path all these days...... but now I need not do that anymore :)
1. Check the current version of Java using the command

java -version

This may result in some output of the form.
java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Server VM (build 10.0-b22, mixed mode)

2. Check the available Java installed in your system.

update-java-alternatives -l

java-6-sun 63 /usr/lib/jvm/java-6-sun
java-gcj 1042 /usr/lib/jvm/java-gcj


3. Now select the Java version you want as default.

update-alternatives --config java
There are 4 alternatives which provide `java'.

Selection Alternative
-----------------------------------------------
1 /usr/bin/gij-4.2
+ 2 /usr/lib/jvm/java-gcj/jre/bin/java
* 3 /usr/lib/jvm/java-6-sun/jre/bin/java
4 /usr/bin/gij-4.1

4. Enter you Java selection number.

Thats it! You are done.........
Now check the new default java using

java -version