一、卸载openjdk
1.查看java安装软件
[root@VM-20-14-centos ~]# rpm -qa|grep java
java-1.8.0-openjdk-1.8.0.312.b07-1.el8_4.x86_64
tzdata-java-2021e-1.el8.noarch
java-1.8.0-openjdk-headless-1.8.0.312.b07-1.el8_4.x86_64
javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch
2.卸载openjdk
yum -y remove tzdata-java.noarch
或
yum -y remove *openjdk*
二、安装oracle jdk8
1.下载jdk8
1)官网下载Linux环境下的jdk1.8
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
账号:youngliu102@163.com
密码:Oracle@123
2)网盘下载
链接:https://pan.baidu.com/s/1Nv5sVVElLMw0h_KRdZ0Ktg
提取码:2drg
2.创建文件目录
mkdir /usr/local/java
3.上传jdk包
官网下载jdk包,上传到服务器/usr/local/java目录
4.解压
tar -vzxf jdk-8u311-linux-x64.tar.gz
5.设置环境变量
vim /etc/profile
末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_311
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
保存退出并刷新配置文件,执行:
source /etc/profile
6.验证是否安装成功
[root@VM-20-14-centos ~]# java -version
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
网友评论