1.下载jdk1.8(需注册Oracle账号)
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
2.安装
解压至自定义目录
tar -xzvf jdk-8u291-linux-x64.tar.gz -C /usr/local/java
3.设置环境变量
vim /etc/profile
在文档末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_171 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
使环境变量生效
source /etc/profile
添加软链接
ln -s /usr/local/java/jdk1.8.0_171/bin/java /usr/bin/java
查看Java版本
java -version