Alternatives is a powerful command under Linux. Can only be performed under root permissions. If there are several commands in the system that are very similar, but cannot be deleted at will, then you can use alternatives to specify a global setting.
Alternatives is often used to install multiple versions of the same software in the same system. For example, in order to develop the need, I need to install JDK1.4.2, but also need JDK1.6.10, how can I ignore the installation path, according to my own meaning, using the Java version I want it.
Here are one by one ways for you.
The alternatives command line executes as follows:
[Root@localhost tools]# Alternatives
Alternatives version 1.3.36-copyright (C) 2001 Red Hat, Inc.
This is 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>
Description
Alternatives--install <link> <name> <path> <priority>
which
Install indicates installation
Link is a symbolic link
Name is the identifier
Path is the way to execute the file
Priority indicates priority
In the case of Java installation, my Fedora 8 has two versions of Java, as follows:
Selection Command
-----------------------------------------------
* 1/usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2/usr/lib/jvm/jre-1.5.0-gcj/bin/java
I installed the Java version "1.4.2_19" in the directory/TOOLS/JDK
[Root@localhost test]# Alternatives--install/usr/bin/java Java/tools/jdk/bin/java 3
[Root@localhost test]# Alternatives--config java
There are 3 programs which provide ' Java '.
Selection Command
-----------------------------------------------
*+ 1/usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2/usr/lib/jvm/jre-1.5.0-gcj/bin/java
3/tools/jdk/bin/java
Enter to keep the current selection[+], or type selection Number:3
I also installed the Java version "1.6.0_12" under the directory/tools/jdk6
[Root@localhost test]# Alternatives--install/usr/bin/java Java/tools/jdk6/bin/java 4
[Root@localhost test]# Alternatives--config java
There are 4 programs which provide ' Java '.
Selection Command
-----------------------------------------------
* 1/usr/lib/jvm/jre-1.7.0-icedtea/bin/java
2/usr/lib/jvm/jre-1.5.0-gcj/bin/java
+ 3/tools/jdk/bin/java
4/tools/jdk6/bin/java
Enter to keep the current selection[+], or type selection number:4
With Alternatives--config Java, you can choose the Java version you want.
Source