1、下载JDK,我是本地下载的。拷贝jdk-8u231-linux-x64.tar.gz到服务器
2、解压/安装
cd /usr/local
mkdir jdk
mv jdk-8u231-linux-x64.tar.gz /jdk/.
cd /jdk
tar -xzvf jdk-8u231-linux-x64.tar.gz
rm -rf jdk-8u231-linux-x64.tar.gz
3、配置java环境变量
vim /etc/profile
export JAVA_HOME=/usr/local/jdk/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
4、使配置文件生效
source /etc/profile
5、java -version 看到下面就是是成功了
java version "1.8.0_231" Java(TM) SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)