Install Java 11 (OpenJDK 11) on RHEL 8 / CentOS 8 / Rocky Linux 8
Install OpenJDK 11 on RHEL 8 / CentOS 8 / Rocky Linux 8
OpenJDK is a free and open-source implementation of the Java Platform, Standard Edition licensed under the GNU General Public License version 2.
sudo yum -y install java-11-openjdk java-11-openjdk-devel$ java -versionopenjdk version "11.0.12" 2021-07-20 LTSOpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)$ which java/usr/bin/java
set Java environment variables
sudo tee /etc/profile.d/java11.sh <<EOFexport JAVA_HOME=\$(dirname \$(dirname \$(readlink \$(readlink \$(which javac)))))export PATH=\$PATH:\$JAVA_HOME/binexport CLASSPATH=.:\$JAVA_HOME/jre/lib:\$JAVA_HOME/lib:\$JAVA_HOME/lib/tools.jarEOF
Source the file to start using it without logging out.
source /etc/profile.d/java11.sh
Install Java SE Development Kit 11 (JDK 11) on RHEL 8 / CentOS 8 / Rocky Linux 8
Download the latest release of JDK 11.
wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/11.0.12%2B8/f411702ca7704a54a79ead0c2e0942a3/jdk-11.0.12_linux-x64_bin.rpm
Then install the package with the rpm command
$ sudo rpm -Uvh jdk-11.0.12_linux-x64_bin.rpmwarning: jdk-11.0.12_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEYVerifying... ################################# [100%]Preparing... ################################# [100%]Updating / installing...1:jdk-11.0.12-2000:11.0.12-ga ################################# [100%]
Confirm Java version installed
[root@iZuf62l0oc6zyphfsga1nuZ data]# java --versionjava 11.0.12 2021-07-20 LTSJava(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237)Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
