[root@localhost ~]# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
1.下载jdk
2.将下载好的软件包解压到指定目录
tar -zxf /usr/local/software/jdk-8u231-linux-x64.tar.gz -C /usr/local/software/java
3.配置JAVA_HOME
打开/etc/profile文件
vim /etc/profile
在文件末尾添加以下内容
export JAVA_HOME=/usr/local/software/java/jdk1.8.0_381
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
4.测试配置是否成功
[root@localhost ~]# java -version
java version "1.8.0_381"
Java(TM) SE Runtime Environment (build 1.8.0_381-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.381-b09, mixed mode)
[root@localhost ~]# echo $JAVA_HOME
/usr/local/software/java/jdk1.8.0_381