How to configure alternative applications / versions to run from same command on Linux
By debashis, Gaea News NetworkFriday, February 5, 2010
Several programs installed in your system may perform same or similar functions., e.g. different text editors or different versions of Java may be present in a single computer.
This may give choice to the users of a system, allowing each one of them to use a different program, if they desire. On the other hand, if the user has not specified a particular preference of program it sometimes becomes complicated. Have you ever faced such problems?
We have experienced these type of problems and tried to sort it out. Let us discuss about the commands that may help you out of your problem.
In our example, we are going to create a link called jstack, which will have a generic name of jstack. This link and generic name are going to be associated with a version of Java, present in our system.
Implementing Our Alternative
Issue the following command to check :-
/usr/sbin/alternatives –config java
In our system there were 2 programs that provide java, like
Selection Command
———————————————–
1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
2 /usr/lib/jvm/java-1.7.0-icedtea-1.7.0.0/bin/java
Step 1
Issue the following command :-
alternatives –install /usr/bin/jstack jstack /usr/java/latest/bin/java 3
It will set the proper alternatives. This command installs a link jstack under /usr/bin directory, links it to a generic name of jstack (in this case), which in turn is linked to the java application.
Step 2
To check whether alternatives has been properly installed or not, issue the command :-
# /usr/sbin/alternatives –config java
Now,
There are 3 programs which provide ‘java’.
Selection Command
———————————————–
* 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
2 /usr/lib/jvm/java-1.7.0-icedtea-1.7.0.0/bin/java
+ 3 /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 3
Thus alternatives can be properly set to run from a common command in Linux.
February 15, 2010: 7:11 pm
This seems to be incorrect (at least on a CentOS 5 system). |
Mick