Skip to content

JDK

RHEL

OracleJDK

bash
# Java 21
yum install -y jdk-21.0.2_linux-x64_bin.rpm
# Java 11
yum install -y jdk-11.0.20_linux-x64_bin.rpm
# Java 1.8
yum install -y jdk-8u381-linux-x64.rpm

OpenJDK

查询

bash
# 通用
yum search java|grep openjdk
# JDK 1.8
yum search java-1.8.0|grep openjdk
# JDK 11
yum search java-11|grep openjdk
# JDK 17
yum search java-17|grep openjdk
# JDK 21
yum search java-21|grep openjdk

安装

bash
# JDK 8
sudo yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel
# JDK 11
sudo yum -y install java-11-openjdk java-11-openjdk-devel
# JDK 17
sudo yum -y install java-17-openjdk java-17-openjdk-devel
# JDK 21
sudo yum -y install java-21-openjdk java-21-openjdk-devel

卸载

bash
# JDK 8
yum -y remove java-1.8.0-openjdk*
# JDK 11
yum -y remove java-11-openjdk*
# JDK 17
yum -y remove java-17-openjdk*
# JDK 21
yum -y remove java-21-openjdk*

卸载

bash
# JDK 8
yum -y remove java-1.8.0-openjdk*
# JDK 11
yum -y remove java-11-openjdk*
# JDK 17
yum -y remove java-17-openjdk*
# JDK 21
yum -y remove java-21-openjdk*

常用操作

bash
#
cd /usr/lib/jvm
ll
#
dirname $(readlink $(readlink $(which java))) 
# 切换JDK
alternatives --config java

Windows