Install OpenJDK 17 LTS on Fedora Linux 35

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.

The tutorial will install the OpenJDK version instead of the default Oracle JDK. The difference between these two is licensing. OpenJDK is an entirely free open-source Java with a GNU General Public License, and Oracle JDK requires a commercial license under the Oracle Binary Code License Agreement. Other differences are release schedules and other factors that come into play; however, performance is pretty much the same.

In the following tutorial, you will learn how to install the latest OpenJDK 17 LTS on Fedora 35 Workstation or Server.


  • Recommended OS: Fedora Linux 35.
  • User account: A user account with sudo or root access.

Update Operating System

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

sudo dnf upgrade --refresh -y

The tutorial will be using the sudo command and assuming you have sudo status.

To verify sudo status on your account:

sudo whoami

Example output showing sudo status:

[joshua@fedora ~]$ sudo whoami

To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Fedora.

To use the root account, use the following command with the root password to log in.


Install Dependency Required

Before you proceed with the installation, run the following command to install or check that the package dnf-plugins-core is installed on your Fedora desktop.

sudo dnf install dnf-plugins-core -y

By default, this should be installed.

The tutorial will utilize the terminal, which can be found in your show applications menu.


How to Install ImageMagick on Fedora 35

Option 1. Install OpenJDK 17 with DNF

The most recommended option is to install OpenJDK using the default Fedora repository. Generally for other distributions, given they focus on being stable and typically having older versions or often slow to deploy any new versions unless its to do with security Fedora nearly always has the most up to date version and quickly, saving time in not having to manually download a manual version as many would do with other distributions.

First, search to find what is available. In your terminal, use the following command.

dnf search OpenJDK Runtime

Example output:

How to Install OpenJDK 17 on Fedora 35

As the above output states, OpenJDK 17 JDE is available using the latest i686 or x86_64. Most users would install the x86_64 version, which accounts for nearly everyone.


How to Install OpenJDK 17 on Fedora 35

To begin the installation, use the following terminal command.

Install OpenJDK 17 – JDK:

sudo dnf install java-latest-openjdk.x86_64

Install OpenJDK 17 – JDK DEVEL:

sudo dnf install java-latest-openjdk-devel.x86_64

Next, by default, on Fedora 35 has OpenJDK 11 installed, you can remove this, but most users would re-configure the default choice of which version is active using the following command.

sudo update-alternatives --config java

This will print out a list, giving you multiple-choice options to input depending on how many versions of OpenJDK you have installed. OpenJDK 11 and the latest version (OpenJDK 17) were installed for the tutorial’s machine.

There are 2 programs which provide 'java'.

  Selection    Command
*+ 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-
   2           java-latest-openjdk.x86_64 (/usr/lib/jvm/java-17-openjdk-

Enter to keep the current selection[+], or type selection number: 2

ENTER 2 and then press the ENTER KEY. Use this same method for future alternative versions.

Confirm the installation by running the following command.

java --version

Example output:

openjdk 17.0.1 2021-10-19
OpenJDK Runtime Environment 21.9 (build 17.0.1+12)
OpenJDK 64-Bit Server VM 21.9 (build 17.0.1+12, mixed mode, sharing)

Updates are handled with the standard dnf update and upgrade commands. However, you can remove them separately or altogether if you no longer require JDK or JRE.

Remove OpenJDK 17 – JDK:

sudo dnf remove java-latest-openjdk.x86_64

Remove OpenJDK 17 – JDK DEVEL:

sudo dnf remove java-latest-openjdk-devel.x86_64

Note, this will remove any unrequited leftover dependencies and thoroughly wipe the installation and data as much as possible from your system.

Test Java – Create Hello World Application

To finish off, it is always handy to test installations of these kinds to confirm everything is working correctly after being installed. The easy way is to create a small test using the famous Hello World example.

First, create the Java program file as follows

sudo nano

Next, add the following Java code into the file:

public class hello {
  public static void main(String[] args) {
    System.out.println("G'day from LinuxCapable!");

Save the file (CTRL+O), then exit (CTRL+X).

Next, compile the code using the following terminal command javac.


Finally, run the Java code with the following command:

java hello

Example output:

How to Install OpenJDK 17 on Fedora 35

Congratulations, everything is working correctly.

Remove Previous Versions of Java

With Fedora and RHEL based distributions, you need the full name to remove Java packages. For users that do not want the default Java 11 installed or, for this matter, any other alternative versions installed and cannot figure out the package name use the following command.

dnf list installed | grep -i jdk

Example output:

[joshua@fedora bin]$ dnf list installed | grep -i jdk
copy-jdk-configs.noarch                           4.0-2.fc35                           @fedora               
java-11-openjdk-headless.x86_64                   1:                 @updates    

As above, you can now remove java-11-openjdk-headless.x86_64. This is just an example, copy the name of any Java package installed with the dnf package manager and use the following example command to remove.

sudo dnf remove java-11-openjdk-headless.x86_64

Comments and Conclusion

In the tutorial, you have learned how to download and install OpenJDK 17 latest version by learning two methods, downloading and future versions and installing with the same process for your Fedora Workstation or Server.


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