Verify Java is Installed on Your System
java –version
Install OpenJDK
sudo yum update
//Update the package repository to ensure you download the latest software
Then, install the JDK or JRE with the following command:
//JDK 8&11
sudo yum install java-1.8.0-openjdk-devel
sudo yum install java-11-openjdk-devel
//JRE 8&11
sudo yum install java-1.8.0-openjdk
sudo yum install java-11-openjdk-devel
Install Specific Version of Java
Run a command that shows all the installed versions on your computer:
sudo alternatives --config java
sudo update-alternatives --config java
The image above shows that there are two alternatives to this system. These choices are represented by numbers 1 (Java 11) and 2 (Java 8).
To change the default version, type the associated number (in this case, 1 or 2) and press Enter.
Set JAVA_HOME Environment Variable On Linux
/usr/lib/jvm/java-11-openjdk-11.0.15.0.9-2.el7_9.x86_64/