1、搜索jdk安装:
yum search java|grep jdk
1
2、安装jdk 1.8:
yum install java-1.8.0-openjdk
查看是否安装成功:
java -version
3、环境变量配置:
JDK`默认安装路径`/usr/lib/jvm
根目录下输入:
ls usr/lib/jvm
命令行输入:
vi /etc/profile(在/etc/profile文件末尾添加如下配置)
#set java environment
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64/jre
PATH=$PATH:$JAVA_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME CLASSPATH PATH
:wq 保存profile文件,执行如下命令刷新环境变量
source /etc/profile
查看环境变量:
echo $JAVA_HOME
echo $PATH
echo $CLASSPATH
如上jdk安装成功
https://blog.csdn.net/weixin_46483006/article/details/125758868