alternatives java_多版本jdk共存--alternatives命令用法
多版本jdk共存--alternatives命令用法说明:alternatives是Linux下的一个功能强大的命令,只能在root权限下执行;如系统中有几个命令功能十分类似,却又不能随意删除,那么可以用 alternatives 来指定一个全局的设置alternatives常用于同一个系统中安装同一软件的多个版本。比如为了开发需要,我需要安装JDK1.6,同时还需要JDK1.7,我怎么样才能忽略
多版本jdk共存--alternatives命令用法
说明:
alternatives是Linux下的一个功能强大的命令,只能在root权限下执行;如系统中有几个命令功能十分类似,却又不能随意删除,那么可以用 alternatives 来指定一个全局的设置
alternatives常用于同一个系统中安装同一软件的多个版本。比如为了开发需要,我需要安装JDK1.6,同时还需要JDK1.7,我怎么样才能忽略安装路径,按照我自己的意思,使用我想要的java版本呢?
使用方法:[root@localhost tools]# alternatives
alternatives version 1.3.49.3 - Copyright (C) 2001 Red Hat, Inc.
This may be freely redistributed under the terms of the GNU Public License.
usage: alternatives --install
[--initscript ]
[--slave ]*
alternatives --remove
alternatives --auto
alternatives --config
alternatives --display
alternatives --set
common options: --verbose --test --help --usage --version
--altdir --admindir ##解释:
alternatives --install
其中,
install表示安装
link是符号链接 (如:java链接;whereis java;java: /usr/bin/java)
name则是标识符(如:java)
path是执行文件的路径(如:jdk执行文件路径:/usr/java/jdk1.7.0_80/bin/java)
priority则表示优先级
以java的安装为例:
我安装了两个jdk:/usr/java/jdk1.7.0_80/bin/java
/usr/java/jdk1.6.0_10/bin/java[root@localhost test]# alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_10/bin/java 3
[root@localhost test]# alternatives --config java
There are 1 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk1.6.0_10/bin/java
Enter to keep the current selection[+], or type selection number: #选择标识,这里先不要选,Ctrl+c断开[root@localhost test]# alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_80/bin/java 4
[root@localhost test]# alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk1.6.0_10/bin/java
2 /usr/java/jdk1.7.0_80/bin/java
Enter to keep the current selection[+], or type selection number:2 #选择标识2,我这里以jdk1.7为默认的java
用alternatives --config java就可以选择你想要的Java版本
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐



所有评论(0)