1、下载jdk安装包
官网:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2、解压
tar -zxvf jdk-8u231-linux-x64.tar.gz
3、配置环境变量
打开文件.bashrc
gedit ~/.bashrc
在文件.bashrc中添加以下内容
export JAVA_HOME=/home/jeremy/Softwares/jdk1.8.0_231 #jdk路径,只需修改这
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
4、刷新配置文件.bashrc; 测试,打开终端输入java
source ~/.bashrc