1、查看JDK软件包列表:
yum -y list java*
2、安装jdk1.8.0的所有文件:
yum -y install java-1.8.0-openjdk*
3、查看JDK是否安装成功:
java -version [centos@kafka3 zookeeper-3.4.14]$ java -version openjdk version "1.8.0_252" OpenJDK Runtime Environment (build 1.8.0_252-b09) OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
4、配置环境变量
JDK默认安装路径/usr/lib/jvm
[centos@kafka3 lib]$ cd /usr/lib/jvm [centos@kafka3 jvm]$ ls java java-1.8.0 java-1.8.0-openjdk java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64 java-openjdk jre jre-1.8.0 jre-1.8.0-openjdk jre-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64 jre-openjdk
在/etc/profile文件最后一行添加如下代码:
# set java environment JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64 PATH=$PATH:$JAVA_HOME/bin CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME CLASSPATH PATH
ESC 退出:wq保存profile文件
执行如下命令使变量生效:
source /etc/profile