How to install multiple Java versions on CentOS 8

Java is one of the most widely used high-level programming languages. Java was first developed by Sun Microsystems. It is used to create a complete application or system that can run on computers or in distributed server environments. In addition, Java is also used to create a small application or applet, which is part of a web page.

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 Enterto 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.

How to install multiple Java versions on CentOS 8 Picture 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
How to install multiple Java versions on CentOS 8 Picture 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 want to change the version above with new alternatives, execute the following command:

$ sudo alternatives --config java
How to install multiple Java versions on CentOS 8 Picture 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 want to set as the default.

4.1 ★ | 74 Vote

May be interested

  • eQuiz - Multiple choice quiz about JAVAeQuiz - Multiple choice quiz about JAVA
    following are multiple-choice questions related to java programming language, there will be 23 questions in total with no answer for each time. let's get started!
  • What is CentOS? Learn about the CentOS operating systemWhat is CentOS? Learn about the CentOS operating system
    used quite a lot in web hosting servers, but for most computer users, centos is still a relatively vague concept. so what is centos? use for what purpose? if you are in need of learning about centos, please refer to the following article!
  • Install CentOS on Windows 10 WSLInstall CentOS on Windows 10 WSL
    join tipsmake.com to find a simple way to manually install centos on windows 10 subsystem for linux and run commands in rhel's yum or rpm repository.
  • JAVA test on P4JAVA test on P4
    the multiple choice questions about java programming will provide you with useful knowledge in the process you apply to learning as well as working with java. invite your reference.
  • JAVA test on P6JAVA test on P6
    multiple choice questions about java programming give you useful knowledge. if you love java programming, don't skip the series of interesting tests below by network administrator.
  • How to install Adobe Flash Player on CentOS 8How to install Adobe Flash Player on CentOS 8
    adobe flash player can also be installed on many types of operating systems, including windows, macos, linux / unix and android. in this article, you will learn how to install adobe flash player on centos 8 using terminal.
  • How to install the latest LibreOffice version on CentOS 8How to install the latest LibreOffice version on CentOS 8
    libreoffice is a powerful and open source office suite. in this article, you will learn how to install libreoffice on centos 8. at the time of writing this article, the latest version of libreoffice 6.4.3 is available for installation.
  • 4 ways to write multi-threaded code in Java4 ways to write multi-threaded code in Java
    multithreading is a method of writing code to execute multiple tasks in parallel. java offers great support for multi-threaded code writing right from java 1.0 version. recent improvements in java have increased the number of ways that code is structured to combine multiple threads in java programs.
  • How to install Java Runtime in UbuntuHow to install Java Runtime in Ubuntu
    java is not installed by default in ubuntu, but is required to run java applications, such as minecraft, on the computer. this article will show you how to install java runtime in ubuntu.
  • Test on JAVA test P5Test on JAVA test P5
    do you like java programming and want to learn useful knowledge to apply to work? to meet the needs of readers, network administrators have collected and sent a series of quiz questions about java programming. invite your reference.