Home

alternatives - huh?

What is this alternatives?

Excerpted (and edited) from the man page on alternatives

alternatives creates, removes, maintains and displays information about the symbolic links comprising the alternatives system...

It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several 'java runtimes' installed at once. This gives choice to the users of a system, allowing each to use a different 'java runtime', if desired, but makes it difficult for a program to make a good choice of 'java' to invoke if the user has not specified a particular preference.

The alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the IcedTea Java runtime and the Sun Java runtime are both installed on the system, the alternatives system will cause the generic name java to refer to IcedTea's java by default.

Yeah but

#/usr/sbin/alternatives
alternatives version 1.3.36 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.

        usage: alternatives --install <link> <name> <path> <priority>
                    [--initscript <service>]
                    [--slave <link> <name> <path>]*
        alternatives --remove <name> <path>
        alternatives --auto <name>
        alternatives --config <name>
        alternatives --display <name>
        alternatives --set <name> <path>

common options: --verbose --test --help --usage --version
                --altdir <directory> --admindir <directory>
        

how do I select a different Java?

# java -version
java version "1.7.0"
IcedTea Runtime Environment (build 1.7.0-b21)
IcedTea 64-Bit Server VM (build 1.7.0-b21, mixed mode)
        
Running the java command shows that IcedTea is the currently referenced java.
# /usr/sbin/alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.7.0-icedtea.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/lib/jvm/jre-1.6.0-sun/bin/java

Enter to keep the current selection[+], or type selection number: 3
        
I select the Sun Java
# java -version
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) Client VM (build 1.6.0_05-b19, mixed mode, sharing)
# 
        
Now when I type the java command the Sun program runs
# /usr/sbin/alternatives --config java

There are 3 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.7.0-icedtea.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/lib/jvm/jre-1.6.0-sun/bin/java

Enter to keep the current selection[+], or type selection number: 3
        
And you can see that the Sun java is the currently referenced java

The + (plus) marks the current selection and the * (asterisk) marks the best option. Best is determined by a priority value entered during install of the option. It's an arbitrary thing so just ignore it.

# /usr/sbin/alternatives --config libjavaplugin.so

There are 2 programs which provide 'libjavaplugin.so'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.7.0-icedtea/lib/i386/gcjwebplugin.so
 + 2           /usr/lib/jvm/jre-sun/plugin/i386/ns7/libjavaplugin_oji.so

Enter to keep the current selection[+], or type selection number: 
You do the same procedure to change the java browser plugin. As you can see, I have the Sun plugin selected here.

The jpackage.org sun-compat RPM that you installed put the Sun version of java and javac in alternatives for you. You installed the reference to Sun's Java plugin.