0%

centos卸载openjdk,并安装jdk

查找本机安装的openjdk

rpm -qa | grep java

python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64
java-1.8.0-openjdk-headless-1.8.0.181-7.b13.el7.x86_64
tzdata-java-2018e-3.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch

卸载

依次使用命令rpm -e --nodeps卸载

rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-7.b13.el7.x86_64

安装jdk1.8

#进入到安装目录
cd /usr/local/

tar -zxvf jdk-8u112-linux-x64.tar.gz
vim /etc/profile

文件末尾增加

#java_home
export JAVA_HOME=/usr/local/bin/jdk1.8.0_112
export PATH=$PATH:$JAVA_HOME/bin

测试

[root@node1 jdk1.8.0_112]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)