1.下载jdk安装包:
https://www.oracle.com/cn/java/technologies/downloads/#java8-windows
2.创建java文件夹:
mkdir /usr/local/java
3.上传安装包并解压:
tar -xzf jdk-xxx.tar.gz
4.修改profile文件:
vim /etc/profile
在文件末尾添加如下:
export JAVA_HOME=/usr/local/java/jdk1.8.0_311
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}
5.重新加载配置:
source /etc/profile
6.输入java -version 查看是否安装成功
java -version