官网下载链接: https://www.oracle.com/java/technologies/downloads/#java8
下载 最后一行 jdk-8u411-linux-x64.tar.gz,并解压:
tar -zxvf jdk-8u411-linux-x64.tar.gz
1、打开~/.bashrc文件
sudo gedit ~/.bashrc
2、写入内容
export JAVA_HOME=/usr/local/java/jdk1.8.0_281
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=${JAVA_HOME}/bin:$PATH
3、更新配置
source ~/.bashrc
打开终端输入:java --version