## 检验系统原版本: ~~~ [root@localhost /]# java -version openjdk version "1.8.0_161" OpenJDK Runtime Environment (build 1.8.0_161-b14) OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode) ~~~ ## 进一步查看JDK信息: ~~~ [root@localhost /]# rpm -qa | grep java python-javapackages-3.4.1-11.el7.noarch java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64 tzdata-java-2018c-1.el7.noarch java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64 java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64 javapackages-tools-3.4.1-11.el7.noarch java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64 ~~~ ## 卸载OpenJDK,执行以下操作: ~~~ [root@localhost /]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-2.b14.el7.x86_64 [root@localhost /]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64 [root@localhost /]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.171-2.6.13.2.el7.x86_64 [root@localhost /]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.171-2.6.13.2.el7.x86_64 ~~~ ## 安装JDK 上传新的jdk-8u191-linux-x64.rpm软件到/usr/local/src/执行以下操作: ~~~ [root@localhost src]# rpm -ivh jdk-8u191-linux-x64.rpm 警告:jdk-8u191-linux-x64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID ec551f03: NOKEY 准备中... ################################# [100%] 正在升级/安装... 1:jdk1.8-2000:1.8.0_191-fcs ################################# [100%] Unpacking JAR files... tools.jar... plugin.jar... javaws.jar... deploy.jar... rt.jar... jsse.jar... charsets.jar... localedata.jar... [root@localhost src]# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) ~~~ ## JDK默认安装在/usr/java中 验证安装 ,执行以下操作,查看信息是否正常: ~~~ [root@localhost src]# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) ~~~ ## 配置环境变量 我的机器安装完jdk-8u191-linux-x64.rpm后不用配置环境变量也可以正常执行javac、java –version操作,因此我没有进行JDK环境变量的配置。但是为了以后的不适之需,这里还是记录一下怎么进行配置,操作如下: 修改系统环境变量文件 ~~~ [root@localhost src]# vi /etc/profile ~~~ ## 向文件里面追加以下内容: ~~~ JAVA_HOME=/usr/java/jdk1.8.0_191-amd64 JRE_HOME=/usr/java/jdk1.8.0_191-amd64/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export JAVA_HOME JRE_HOME PATH CLASSPATH ~~~ ## 使修改生效 ~~~ [root@localhost /]# source /etc/profile [root@localhost /]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_191-amd64/bin:/usr/java/jdk1.8. ~~~