wget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
tar -zxvf jdk-21_linux-x64_bin.tar.gz
创建jdk安装目录
mkdir /usr/local/java/
将解压出来的jdk安装包移动到新建的jdk安装目录下
mv ./jdk-21.0.5/ /usr/local/java/
将环境变量配置添加到 /etc/profile 文件中
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk-21.0.5/
export JRE_HOME=$JAVA_HOME/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
加载配置文件
source /etc/profile