下载

https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html
下载压缩包
img.png

解压验证

1
tar -zxvf jdk-17_linux-x64_bin.tar.gz

解压后可以得到目录jdk-17.0.10,进入bin目录,查看java版本

1
2
3
4
5
cd jdk-17.0.10/bin
./java -version
java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

配置环境变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sudo vim /etc/profile

# 在文件末尾添加以下内容
export JAVA_HOME=/usr/local/jdk-17.0.10
export PATH=$JAVA_HOME/bin:$PATH

# 生效配置文件
source /etc/profile

#验证
echo $JAVA_HOME
/usr/local/jdk-17.0.10

java -version
java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

收工