centos7安装jdk8

1.卸载系统自带的openJDK

rpm -qa | grep java | xargs rpm -e --nodeps

2.把下载好的jdk-8u221-linux-x64.tar.gz拷贝到centos相应的目录(如:/usr/local/java)并解压

tar -zxvf jdk-8u221-linux-x64.tar.gz

3.配置JDK环境变量

export JAVA_HOME=/usr/local/java/jdk1.8.0_221
 
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
 
export PATH=$PATH:$JAVA_HOME/bin

4.使环境变量生效

source /etc/profile

 

你可能感兴趣的:(centos7安装jdk8)