从官网下载包,
https://download.oracle.com/otn/java/jdk/8u231-b11/5b13a193868b4bf28bcb45c792fce896/jdk-8u231-linux-x64.tar.gz
解压安装包
#解压
tar -zvxf jdk-8u231-linux-x64.tar.gz
#移动他local目录
mv jdk1.8.0_231 /usr/local/
#配置环境变量
vi /etc/profile
#在文件最后添加java环境变量
export JAVA_HOME=/usr/local/jdk1.8.0_231
export JRE_HOME=/usr/local/jdk1.8.0_231/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
#保存,退出
#使配置立即生效
source /etc/profile
#测试
java -version
#以下是输出内容
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) Server VM (build 25.231-b11, mixed mode)