centos7卸载自带jdk安装jdk1.8(附下载地址)

1. 查找jdk安装信息

[root@centos75-02 ~]# rpm -qa |grep java
java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
tzdata-java-2018c-1.el7.noarch
python-javapackages-3.4.1-11.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64

2. 卸载对应jdk

[root@centos75-02 ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64
[root@centos75-02 ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64

3.安装包安装

下载地址https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html需要oracle账号
jdk1.8u261版本
或者到我的网盘下载也行,有两个版本rpm和解压包的 https://cloud.189.cn/t/zem6juQ73mQf(访问码:4idc)

[root@centos75-01 ~]# rpm -ivh jdk-8u181-linux-x64.rpm
warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8-2000:1.8.0_181-fcs        ################################# [100%]
Unpacking JAR files...
        tools.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
        rt.jar...
        jsse.jar...
        charsets.jar...
        localedata.jar...

4.修改配置文件

[root@centos75-02 ~]# vi /etc/profile
#添加如下内容
export JAVA_HOME=/usr/java/jdk1.8.0_251-amd64
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

5.配置文件生效

[root@centos75-01 ~]# source /etc/profile
[root@centos75-01 ~]# java -version #查看jdk版本
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

你可能感兴趣的:(centos7卸载自带jdk安装jdk1.8(附下载地址))