



*+ 2 java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.8_1.x86_64/jre/bin/java)Įnter to keep the current selection, or type selection number:Ġ3- Finally, enter the number of the Java version you want to use as the default and press Enter Setting the JAVA_HOME Environment Variable So, if you installed multiple Java versions on your CentOS system, you can use the alternatives command to set which Java version will be used by default.Ġ1- To check what Java version is set as the default one, type: $ java -versionĠ2- If you want to change the default version, use the command alternatives to list all the installed Java versions. OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode) OpenJDK Runtime Environment (build 1.8.0_252-b09) OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing)Ġ1- If your application requires Java 8, so, you can install it by excuting the below command: $ sudo dnf install java-1.8.0-openjdk OpenJDK Runtime Environment 18.9 (build 11.0.7+10-LTS) Installing OpenJDK 11 on CentOSĠ1- To install the OpenJDK 11 on CentOS 8, run the following command as root or user with sudo privileges: $ sudo dnf install java-11-openjdkĠ2- Once the installation is complete, you can verify it by checking the Java version: $ java -version In this tutorial, we will explain how to install one or more Java ( OpenJDK) versions on CentOS 8 and how to set the default Java via alternatives. Java is one of the most popular programming languages used to build different types of applications and systems.
