1.准备jdk文件
/home/jdk-8u311-linux-x64.tar.gz
2.新建jdk安装目录
sudo mkdir -p /usr/local/java
3.jdk放到新建目录
sudo mv /home/jdk-8u311-linux-x64.tar.gz /usr/local/java
4.解压jdk
sudo tar -zxvf jdk-8u311-linux-x64.tar.gz
5.配置环境变量
// 打开文件
sudo vi ~/.bashrc
// 写入环境变量
export JAVA_HOME=/usr/local/java/jdk1.8.0_311
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:{JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
6.刷新环境变量
source ~/.bashrc
7.验证安装是否成功
java -version
// 输出如下
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
标签:java,jdk,tar,sudo,export,ubuntu,HOME,安装
From: https://www.cnblogs.com/unlockth/p/17119757.html