CentOS7 下安装 JDK 发表于 2023-09-01 更新于 2023-09-02 分类于 开发环境 阅读次数: 一、卸载系统自带的 OpenJDK1234567891011# 查看[root@docker ~]# java -versionopenjdk version "1.8.0_222"OpenJDK Runtime Environment (build 1.8.0_222-b10)OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode) # 卸载rpm -qa | grep openjdk | xargs rpm -e --nodeps# 确认java -version 二、下载解压12345# 下载wget https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz# 解压tar -zxvf ./jdk-8u202-linux-x64.tar.gz -C /usr/local/ 三、配置环境变量123456789# vim /etc/profile# Java Environmentexport JAVA_HOME=/usr/local/jdk1.8.0_202export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jarexport PATH=$PATH:${JAVA_HOME}/bin# 使环境变量文件生效source /etc/profile 四、测试1234[root@localhost local]# java -versionjava version "1.8.0_202"Java(TM) SE Runtime Environment (build 1.8.0_202-b08)Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)