Linux下卸载openjdk,安装jdk 1.查看java版本 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安装软件 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

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.解压

tar -vzxf jdk-8u191-linux-x64.tar.gz

6.设置环境变量

vim /etc/profile #java export JAVA_HOME=/data/jdk1.8.0_221 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib

保存退出,执行

source /etc/profile

7.测试 java -version