- 新建目录
cd /usr/local/
mkdir java
cd java
2.下载jdk
wget https://download.oracle.com/java/18/latest/jdk-18_linux-x64_bin.tar.gz
3.解压
tar -zxvf jdk-18_linux-x64_bin.tar.gz
4.配置到环境变量
vim /etc/environment
增加如下
JAVA_HOME=/usr/local/java/jdk-18.0.1.1
JRE_HOME=/usr/local/java/jdk-18.0.1.1/jre
CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
PATH=.:${JAVA_HOME}/bin:$PATH
5.在刷新一下环境变量
source /etc/environment
6.ok
java -version