0.下载jdk
可以从官网下载,附下载链接:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
1.解压缩,随便解压到哪个文件夹,我习惯在/usr/local/java下
cd /usr/local/java
tar -xzvf /root/jdk/jdk-8u191-linux-x64.tar.gz
2.配置环境变量
vi /etc/profile #在末尾插入如下代码 export JAVA_HOME=/usr/local/java/jdk1.8.0_191 export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar export PATH=$PATH:$JAVA_HOME/bin
3.应用环境变量
source /etc/profile
4.测试是否安装成功
java -version
安装成功