1.打开url选择jdk1.8下载
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
现在下载需要账号下载
3.安装
(1)创建安装目录
mkdir /usr/local/java/
(2)解压至安装目录
tar -zxvf jdk-8u231-linux-x64.tar.gz -C /usr/local/java/
4.设置环境变量
打开文件
vim /etc/profile
在末尾添加
export JAVA_HOME=/usr/local/java/jdk1.8.0_231
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_231/bin/java /usr/bin/java
检查
java -version