Linux openjdk 切換為java jdk
先配置完java環(huán)境變量
#當(dāng)下是openjdk環(huán)境
[root@localhost jdk1.8.0_231]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
#/usr/bin/java 為openjdk路徑 氨距,/usr/local/jdk1.8/jdk1.8.0_231為自己安裝的jdk
[root@localhost jdk1.8.0_231]# sudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8/jdk1.8.0_231/bin/java 300
[root@localhost jdk1.8.0_231]# sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8/jdk1.8.0_231/bin/javac 300
#如果還不行
[root@localhost jdk1.8.0_231]# alternatives --config java
共有 2 個(gè)提供“java”的程序设褐。
選項(xiàng) 命令
-----------------------------------------------
*+ 1 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b02.el7_6.x86_64/jre/bin/java)
2 /usr/local/jdk1.8/jdk1.8.0_231/bin/java
按 Enter 保留當(dāng)前選項(xiàng)[+],或者鍵入選項(xiàng)編號(hào):2
[root@localhost jdk1.8.0_231]# java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)