centos 安装 JDK

1:先查看有没有安装JDK;使用Java-version命令

1.1 :查看所有版本 yum search java|grep jdk ; 选择自己要安装的版本

2:安装 yum install java-1.8.0-openjdk-devel.x86_64 ;

3:配置环境变量

3.1 找到JDK安装路径

whic java

ls -lr

ls -lrt

/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre/bin/java

配置环境变量

添加

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

source /etc/profile

echo $JAVA_HOME


参考

https://www.hangge.com/blog/cache/detail_2651.html#:~:text=%E5%9C%A8%20CentOS%207%20%E7%B3%BB%E7%BB%9F%E4%B8%AD%E5%AE%89%E8%A3%85%20jdk%20%E9%80%9A%E5%B8%B8%E6%9C%89%E5%A6%82%E4%B8%8B%E5%87%A0%E7%A7%8D%E6%96%B9%E5%BC%8F%EF%BC%9A%E6%89%8B%E5%8A%A8%E4%B8%8B%E8%BD%BD%E5%AE%89%E8%A3%85%E5%8C%85%E8%BF%9B%E8%A1%8C%E5%AE%89%E8%A3%85%EF%BC%8C%E9%80%9A%E8%BF%87%20yum%20%E5%AE%89%E8%A3%85%EF%BC%8C%E4%BB%A5%E5%8F%8A%E4%BD%BF%E7%94%A8%E4%BD%BF%E7%94%A8,yum%20install%20%E5%AE%89%E8%A3%85%20jdk%20%EF%BC%8C%E6%98%AF%E4%B8%8D%E4%BC%9A%E8%87%AA%E5%8A%A8%E9%85%8D%E7%BD%AE%20JAVA_HOME%20%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E7%9A%84%E3%80%82%20%E5%A6%82%E6%9E%9C%E6%9C%89%E4%B8%80%E4%BA%9B%E6%9C%8D%E5%8A%A1%E4%BE%9D%E8%B5%96%E8%BF%99%E4%B8%AA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E5%B0%B1%E4%BC%9A%E5%90%AF%E5%8A%A8%E5%A4%B1%E8%B4%A5%E3%80%82

你可能感兴趣的:(centos 安装 JDK)