一、创建软件存放目录
[root@m1 ~]# mkdir -p /data/software/ && cd /data/software/
二、上传jdk安装包
官网下载:https://www.oracle.com
[root@m1 /data/software]# wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
三、解压安装包
[root@m1 /data/software]# tar xf jdk-17_linux-x64_bin.tar.gz -C /opt/
[root@m1 /data/software]# cd /opt/
[root@m1 /opt]# ll
drwxr-xr-x 9 root root 136 Jan 24 16:53 jdk-17.0.2
四、做软连接
[root@m1 /opt]# ln -s jdk-17.0.2/ jdk
[root@m1 /opt]# ll
lrwxrwxrwx 1 root root 11 Jan 24 16:53 jdk -> jdk-17.0.2/
drwxr-xr-x 9 root root 136 Jan 24 16:53 jdk-17.0.2
五、配置环境变量
[root@m1 /opt]# echo 'export PATH=/opt/jdk/bin:$PATH' > /etc/profile.d/java.sh
[root@m1 /opt]# cat /etc/profile.d/java.sh
export PATH=/opt/jdk/bin:$PATH
六、刷新环境变量
[root@m1 /opt]# source /etc/profile.d/java.sh
七、验证jdk版本
[root@m1 /opt]# java -version
java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)