How to Install Java 16 (OpenJDK 16) on Fedora Linux

Java is a general-purpose, class-based, object-oriented multipurpose programming language that is popular due to the design of having lesser implementation dependencies, meaning that the compiled Java code can be run on all platforms that support Java without the need for recompilation. Java is also fast, secure, and reliable, therefore. It is widely used for developing Java applications in laptops, data centers, game consoles, scientific supercomputers, cell phones, etc.

In the following tutorial, you will learn how to install the latest Java 16 (OpenJDK 16) on Fedora Linux.

Prerequisites

  • Recommended OS: Fedora Linux 34 (Newer versions will work also)
  • User account: A user account with sudo or root access.

Updating Operating System

Update your Fedora Linux operating system to make sure all existing packages are up to date:

sudo dnf update && sudo dnf upgrade -y

Install Java 16 for Fedora Linux

Verify if Java is stalled

The first step is to check if your Fedora operating system has any Java versions preinstalled. To do this, use the following command:

java -version

Example output:

openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment 18.9 (build 11.0.12+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7, mixed mode, sharing)

From the output Java, 11 (OpenJDK 11) is installed. By default, Fedora Linux operating systems come with Java installed.

Search Repository for Latest Version of Java

As most would know, Java 11 is quite outdated, and Fedora Linux being an upstream module with the latest packages, you can search for different versions using the dnf search command as follows:

sudo dnf search openjdk

You will receive a large list of options. In installing Java 16, you will see the latest tag, which equals the latest java version on offer.

Example:

How to Install Java 16 (OpenJDK 16) on Fedora Linux

You can install other versions of Java, both OpenJDK, and Oracle Java SE. The latest Fedora Linux 34 version OpenJDK 1.8, OpenJDK 11, and OpenJDK 16 are available.

Install Java

From the list, you will see java-latest-openjdk.x86_64; this is the latest version of OpenJDK that you will need to execute to install Java 16. To do this, use the following command:

sudo dnf install java-latest-openjdk.x86_64

Example output of dependencies that will be installed:

How to Install Java 16 (OpenJDK 16) on Fedora Linux

Type Y, then press enter key to proceed with the installation.

Once installed, you will need to swap from the existing Java 11 to the latest Java 16 OpenJDK you just installed.

To do this, use the following command:

sudo alternatives --config java

Example output:

How to Install Java 16 (OpenJDK 16) on Fedora Linux

From the output above, you would type 2 and press the enter key to select the latest Java OpenJDK version (Java 16).

To check if the swap has been successful, use the version command to verify:

java -version

Example output:


openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment 21.3 (build 16.0.2+7)
OpenJDK 64-Bit Server VM 21.3 (build 16.0.2+7, mixed mode, sharing)

Congratulations, you have installed the latest version of Java currently available for Fedora Linux.

Comments and Conclusion

In the tutorial, you have learned how to download and install Java 16 (OpenJDK 16) latest version, along with downloading and future versions and installing with the same process for your Fedora 8 operating system.



Follow LinuxCapable.com!

Like to get automatic updates? Follow us on one of our social media accounts!