[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文件文章来源:https://www.toymoban.com/news/detail-758780.html
vim /etc/profile
在文件末尾添加以下内容文章来源地址https://www.toymoban.com/news/detail-758780.html
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
到了这里,关于Linux配置JAVA_HOME的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!