centsos 7 删除自带jdk安装自定义jdk8

甲骨文官网地址:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

如何清除自带jdk8:

  rpm -qa | grep java

查询如下:

[root@hostuser chenquan]# rpm -qa | grep java
java-1.7.0-openjdk-headless-1.7.0.221-2.6.18.0.el7_6.x86_64
java-1.7.0-openjdk-1.7.0.221-2.6.18.0.el7_6.x86_64
java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64
tzdata-java-2019a-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch

保留.norarch结尾文件,其他删除:

[root@hostuser chenquan]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.221-2.6.18.0.el7_6.x86_64
[root@hostuser chenquan]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.221-2.6.18.0.el7_6.x86_64
[root@hostuser chenquan]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
[root@hostuser chenquan]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64

再次过滤检查删除干净:
[root@hostuser chenquan]# rpm -qa | grep java

javapackages-tools-3.4.1-11.el7.noarch
tzdata-java-2019a-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch

mkdir /usr/local/java

cd /usr/local/java

上传jdk8---tar.gz:

wget  https://download.oracle.com/otn/java/jdk/8u211-b12/478a62b7d4e34b78b671c754eaaf38ab/jdk-8u211-linux-x64.tar.gz

tar -zxvf   jdk-8u211-linux-x64.tar.gz

 

  vi /etc/profile 

export JAVA_HOME=/usr/local/java/jdk1.8.0_211
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

以上三行添加结束后 刷新环境变量执行如下:

source /etc/profile 

完成后检查jdk安装情况:

 

 

 查看 java version 

 

 

 环境变量配置结束

 

 

posted @ 2019-05-02 21:17  不带R的墨菲特  阅读(1622)  评论(0编辑  收藏  举报