Tuesday, July 19, 2011

/etc/alternatives/

Linux allows different implementation of a single command/utility co-exist. For example you can install both open JDK and sun JDK at a time on Linux and can also make one of them as default. The default selection is made using links in the file system. This works as:-

$which java
/usr/bin/java

$ls -l /usr/bin/java
/usr/bin/java -> /etc/alternatives/java

$ls -l /etc/alternatives/java
/etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-sun/bin/java

If we type command java on command prompt then /usr/bin/java is invoked. The /usr/java/bin points to /etc/alternatives/java and /etc/alternatives/java points to /usr/lib/jvm/jre-1.6.0-sun/bin/java. So the target of the command java becomes /usr/lib/jvm/jre-1.6.0-sun/bin/java


On Ubuntu, there is a graphical utility which lets you to change/configure the alternatives. But this is missing from the default install of openSUSE. But on the openSUSE this can be easily achieved by command line as -

update-alternatives --config java
 
This command will list all available options and will ask you to enter to select one of them.

No comments:

Post a Comment