在update-alternatives中安装jdk

时间:2021-07-16 15:20:18

update-alternatives --install /usr/bin/java java /opt/jdk1.6.0_45/bin/java 16045 --slave /usr/bin/javac javac /opt/jdk1.6.0_45/bin/javac --slave /usr/bin/jar jar /opt/jdk1.6.0_45/bin/jar --slave /usr/bin/jarsigner jarsigner /opt/jdk1.6.0_45/bin/jarsigner --slave /usr/bin/javadoc javadoc /opt/jdk1.6.0_45/bin/javadoc --slave /usr/bin/javah javah /opt/jdk1.6.0_45/bin/javah --slave /usr/bin/javap javap /opt/jdk1.6.0_45/bin/javap --slave /usr/bin/javaws javaws /opt/jdk1.6.0_45/bin/javaws

update-alternatives的一个缺点是不能通过命令单独修改slave,但可以手工修改配置文件及建立相应的符号链接来达到目的:(可参见 man update-alternatives)
/var/lib/alternatives/java

没有的slave项用空行表示

符号链接有两层:

1. /usr/bin/... -> /etc/alternatives/...

2. /etc/alternatives/... -> 实际的位置