Update alternatives in debian etch

23 May 2008
Posted by stylesen
In Debian it is sometimes possible to have different alternatives for the same program. One such is 'java'. We have the GNU gcj and Sun provided java compilers available in Debian etch. I had the following java installed in my box as default
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I wanted to switch to Sun provided java version.
sudo apt-get install sun-java5-jdk sun-java5-jre
Once this gets successfully installed, we need to choose which java compiler we would like to use which is made is by the debian 'alternatives' system. It is very simple:
$ sudo update-alternatives --config java

There are 3 alternatives which provide `java'.

  Selection    Alternative
-----------------------------------------------
          1    /usr/bin/gij-wrapper-4.1
*+        2    /usr/lib/jvm/java-gcj/jre/bin/java
          3    /usr/lib/jvm/java-1.5.0-sun/jre/bin/java

Press enter to keep the default[*], or type selection number: 3
Using `/usr/lib/jvm/java-1.5.0-sun/jre/bin/java' to provide `java'.
Now you have java provided by Sun Micros from your alternatives which could be verified by the following:
$ java -version
java version "1.5.0_14"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)
Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)