Mac安装OpenJDK17
、OpenJDK17 下载地址:
- 官方OpenJDK:前往下载
- 微软OpenJDK:前往下载(Win/Mac/Linux)
- 红帽OpenJDK:前往下载(Win版本)
- 华为OpenJDK:前往下载(Linux版本)
- 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
参考: