alternatives命令介绍:
alternatives --install <link> <name> <path> <priority>
其中,
install表示安装
link是符号链接
name则是标识符
path是执行文件的路径
priority则表示优先级
比如在某个目录下安装jdk:
在目录/tools/jdk6下安装了java version "1.6.0_12"
[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
用alternatives --config java就可以选择你想要的Java版本
alternatives --display java
查询
alternatives --remove java /home/server/jdk1.6.0_21/bin/java 删除
本文转自chenzudao51CTO博客,原文链接: http://blog.51cto.com/victor2016/1958548,如需转载请自行联系原作者