PHP笔记网

革命尚未成功,同志仍须努力下载JDK17

作者:Albert.Wen  添加时间:2022-03-05 20:55:43  修改时间:2024-11-21 08:30:56  分类:Linux软件安装/参数优化  编辑

CentOS 7安装Maven


Mac安装OpenJDK17 、OpenJDK17 下载地址:

  1. 官方OpenJDK:前往下载
  2. 微软OpenJDK前往下载(Win/Mac/Linux)
  3. 红帽OpenJDK:前往下载(Win版本)
  4. 华为OpenJDK:前往下载(Linux版本)
  5. Oracle JDK8:前往下载

卸载JDK

步骤一:查询系统是否以安装jdk

[root@CentOS7-1 ~]#  rpm -qa|grep java

java-1.8.0-openjdk-devel-1.8.0.282.b08-1.el7_9.x86_64
javapackages-tools-3.4.1-11.el7.noarch
java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64
java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
tzdata-java-2021a-1.el7.noarch
java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64
python-javapackages-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.282.b08-1.el7_9.x86_64

步骤二:卸载已安装的jdk

把上述含有openjdk字样的包逐个删除:

[root@CentOS7-1 ~]# rpm -e --nodeps java-1.8.0-openjdk-devel-1.8.0.282.b08-1.el7_9.x86_64
[root@CentOS7-1 ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64
[root@CentOS7-1 ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
[root@CentOS7-1 ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.261-2.6.22.2.el7_8.x86_64
[root@CentOS7-1 ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.282.b08-1.el7_9.x86_64

安装JDK

步骤一:下载Linux版本的jdk(并上传到Linux上)

建议先用迅雷下载到本地PC机,然后上传到Linux服务器

步骤二:解压jdk包到指定目录

cd /alidata/tmp
tar -xzvf ./openjdk-17.0.2_linux-x64_bin.tar.gz
mkdir -pv /alidata/server/java/jdk17
\cp -rf ./jdk-17.0.2/*  /alidata/server/java/jdk17/

步骤三:编辑/etc/profile文件,配置环境变量

vim /etc/profile

在末尾添加:

# Java Env
export JAVA_HOME=/alidata/server/java/jdk17
export PATH=$PATH:$JAVA_HOME/bin

步骤四:使profile生效

source /etc/profile

确认Java版本:

[root@CentOS7-1 ~]# java -version
openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

[root@CentOS7-1 ~]# echo $JAVA_HOME
/alidata/server/java/jdk17

 

 

参考:

  1. CentOS7安装OpenJDK
  2. CentOS7卸载 OpenJDK 安装Sun的JDK8