1. 查看 java 版本
[root@CFDB2 ~]# java -version openjdk version "1.8.0_171" OpenJDK Runtime Environment (build 1.8.0_171-b10) OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
2. 查看 java 安装软件
[root@CFDB2 ~]# rpm -qa|grep java tzdata-java-2018e-3.el7.noarch java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64 java-1.7.0-openjdk-headless-1.7.0.181-2.6.14.8.el7_5.x86_64 java-1.7.0-openjdk-1.7.0.181-2.6.14.8.el7_5.x86_64 javapackages-tools-3.4.1-11.el7.noarch python-javapackages-3.4.1-11.el7.noarch java-1.8.0-openjdk-headless-1.8.0.171-8.b10.el7_5.x86_64 [root@CFDB2 ~]#
3. 卸载 openjdk【 .noarch可以不用删除 】
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.101-3.b13.el7_2.x86_64
.......
4. 上传 jdk 包
官网下载 jdk 包,上传到服务器上
5. 解压
[root@localhost yangchao]# tar -vzxf jdk-8u191-linux-x64.tar.gz
6. 设置环境变量
[root@localhost yangchao]# vim /etc/profile
profile 文件末尾添加
#java_home export JAVA_HOME=/yangchao/jdk1.8.0_191 export PATH=$PATH:$JAVA_HOME/bin
保存退出,执行
[root@localhost yangchao]# source /etc/profile
7. 测试
[root@localhost yangchao]# 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) [root@localhost yangchao]#