[root@localhost ~]# lsb_release -aNo LSB modules are available.Distributor ID: UbuntuDescription:Ubuntu 22.04.3 LTSRelease:22.04Codename: 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_381export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH

4.测试配置是否成功

[root@localhost ~]# java -versionjava 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