[root@VM_0_2_centos jdk1.8.0_281]# update-alternatives --display java java - status is auto. ?link currently points to /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java - family java-1.8.0-openjdk.x86_64 priority 1800242 ?
这里显示了默认openjdk的优先级是1800242,我这里新安装的jdk版本是1.8.0_281,修改优先级是 1800281。
我的jdk解压安装路径是/home/software/jdk1.8.0_281,执行命令如下
[root@VM_0_2_centos jdk1.8.0_281]# update-alternatives --install /usr/bin/java java /home/software/jdk1.8.0_281/bin/java 1800281
[root@VM_0_2_centos jdk1.8.0_281]# update-alternatives --config java
There are 3 programs which provide 'java'.
? Selection ? ?Command ----------------------------------------------- ? ?1 ? ? ? ? ? java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el7_7.x86_64/jre/bin/java) ? ?2 ? ? ? ? ? java-1.7.0-openjdk.x86_64 (/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.251-2.6.21.0.el7_7.x86_64/jre/bin/java) *+ 3 ? ? ? ? ? /home/software/jdk1.8.0_281/bin/java
Enter to keep the current selection[+], or type selection number: 3 [root@VM_0_2_centos jdk1.8.0_281]# java -version java version "1.8.0_281" Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode) ?
结果是已经修改成功。
|