Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Install Multiple Java Versions on CentOS 8

Learn how to Install Multiple Java Versions with clear steps, useful examples, and practical tips. Complete the task correctly and avoid common mistakes.

Table of Contents

This updated guide explains how to Install Multiple Java Versions on CentOS 8 through clear steps, practical examples, and important checks that help prevent common errors.

In this article, readers will learn how to install different versions of Java on CentOS 8.

Install Java on CentOS 8

Perform the following steps to install Java on CentOS 8:

1. First, you need to log in as an administrator or root user on the system.

2. Open a terminal with keyboard shortcuts Ctrl+ Alt+ T.

Install OpenJDK 11

The best way is to install the latest Java version JDK 11. Some Java-based applications may need a specific version of Java, so in this situation, you need to read the application documentation first.

You will run the following command to install OpenJDK11 on CentOS 8 system:

$ sudo dnf install java-11-openjdk-devel

During installation, a confirmation prompt from the user will be displayed on the Terminal. Click Y, and then click Enter to allow the installation of Java packages on the system.

You should see the Complete status displayed for the installation of OpenJDK 11 on the Terminal.

Install Multiple Java Versions on CentOS 8 — Install OpenJDK 11 screenshot 1 You should see the Complete status displayed for the installation of OpenJDK 11 on the Terminal

Check the Java Version

After installation is complete, you can now verify Java installation by displaying the installed Java version. For this purpose, you need the following command:

$ java -version

At this stage, Java has been successfully installed on the CentOS 8 system.

You can also install a headless Java version on CentOS 8, which supports the minimum Java runtime required for application execution, without the use of a GUI (i. e. without a mouse or keyboard). and the support of the monitor system). Better headless version for server applications.

You need to type the following command to install only Headless OpenJDK 11 version on the system:

$ sudo dnf install java-11-openjdk-headless
Install Multiple Java Versions on CentOS 8 — Check the Java Version screenshot 2 Install the headless OpenJDK 11 version on the system

Install OpenJDK 8

Similarly, you can install OpenJDK 8 on your system. The default CentOS 8 repository contains the latest two major versions of Java LTS, Java 8 and 11. OpenJDK 8 is also a commonly used version. To install Java 8, you need to execute the following command:

$ sudo dnf install java-1.8.0-openjdk-devel

After completing the installation of Java 8, you can now verify it by checking the version information as follows:

$ java -version

You can also install headless versions of Java 8.

Set the Default Version of Java

If there are multiple versions of Java installed on CentOS 8, in this case, you can use the default version of Java (that is, when you type java on Terminal, which version will be used as the default) like after:

$ java -version

If you may need to change the version above with new alternatives, execute the following command:

$ sudo alternatives --config java
Install Multiple Java Versions on CentOS 8 — Set the Default Version of Java screenshot 3 A list of installed Java versions is displayed

After running the above command, a list of installed Java versions will be displayed on the Terminal. Now, choose the number that corresponds to the version you may need to set as the default.

FAQ

What is the easiest way to Install Multiple Java Versions on CentOS 8?

Start with the requirements in this guide, then follow each step in order. Check the result after every major change so problems are easier to identify.

Can beginners follow these instructions?

Yes. The process is organized into practical steps, and you can repeat any step before moving forward.

What should I check if the method does not work?

Confirm your software or device version, permissions, settings, file format, and internet connection when the task depends on online services.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.