Fedora 44’s OpenJDK package set matters before you run DNF because the default Java line is OpenJDK 25 while older Java 21 package names no longer resolve in the standard repositories. To install OpenJDK on Fedora, choose the package track that matches your project, then use alternatives only when more than one Java major is installed.
The Fedora repositories provide java-25-openjdk-devel for the default development kit and java-latest-openjdk-devel as the moving feature-release track, currently OpenJDK 26. Java 21 workloads need a maintained vendor JDK or another verified package source on Fedora 44.
Install OpenJDK on Fedora
Update Fedora Before Installing OpenJDK
Refresh Fedora’s package metadata before installing a JDK. The -y flag accepts the confirmation prompt automatically.
sudo dnf upgrade --refresh -y
These commands use
sudofor package-management tasks that need root privileges. If your account is not configured for administrative access yet, follow the guide on how to add a user to sudoers on Fedora first.
Compare Fedora OpenJDK Packages
Choose the Java line your project targets instead of installing the newest package by habit. For development work, use a versioned -devel package so java, javac, jar, and related tools stay on the same major release.
| Track | Fedora 44 Package | Status | Choose It When |
|---|---|---|---|
| OpenJDK 25 | java-25-openjdk-devel | Available from Fedora repositories as 25.0.x | You want Fedora’s default Java line for current development work |
java-latest-openjdk | java-latest-openjdk-devel | Available from Fedora repositories as OpenJDK 26.0.x | You are testing the newest feature release and can tolerate major-version jumps over time |
| OpenJDK 21 | No standard Fedora 44 package | java-21-openjdk-devel is not available in the standard repositories | Your project requires Java 21 from another maintained source |
Fedora package names differ from Debian and Ubuntu. Install java-25-openjdk-devel on Fedora 44, not openjdk-25-jdk. Fedora package metadata lists java-25-openjdk-devel and java-latest-openjdk-devel for Fedora 44.
Start with
java-latest-openjdkonly when you intentionally want Fedora’s rolling feature-release track. It does not stay pinned to an LTS branch, and Fedora gives it a very lowalternativespriority when a default Java line is also installed.
After you choose the Java line, match the package flavor to how the system will use Java:
-develpackages such asjava-25-openjdk-develinclude the runtime plus compiler tools likejavac,jar, andjavadoc; use them for development work and most local test environments.- Runtime packages such as
java-25-openjdkkeep the desktop-capable Java runtime but omit compiler tools; use them when the machine only needs to launch Java applications. -headlesspackages such asjava-25-openjdk-headlessskip GUI libraries and keep the runtime leaner; use them on Server or minimal installs, containers, CI runners, and other non-GUI hosts.
Install OpenJDK 25 on Fedora
OpenJDK 25 is Fedora 44’s default Java line, so it is the safest starting point for most new work on this release.
sudo dnf install java-25-openjdk-devel -y
If you only need to run Java applications, swap the package name to java-25-openjdk or java-25-openjdk-headless. The -devel package installs the matching compiler tools and runtime components.
Confirm that the Fedora package is installed:
rpm -q java-25-openjdk-devel
java-25-openjdk-devel-25.0.3.0.9-1.fc44.x86_64
Install java-latest-openjdk on Fedora
The java-latest-openjdk track follows Fedora’s newest feature release instead of staying pinned to an LTS branch. On Fedora 44, that package currently maps to OpenJDK 26.
sudo dnf install java-latest-openjdk-devel -y
Verify that the package itself is installed before you switch it into place:
rpm -q java-latest-openjdk-devel
java-latest-openjdk-devel-26.0.1.0.8-0.1.fc44.x86_64
Check Java 21 Availability on Fedora
Fedora 44 does not currently publish java-21-openjdk-devel in the standard repositories. Check availability with repoquery before trying older Fedora package commands:
dnf -q repoquery --available java-21-openjdk-devel
No package output means Fedora has no standard-repository Java 21 package for this release. Do not hide the missing package with --skip-unavailable; that only skips Java 21 and leaves it uninstalled.
Switch OpenJDK Versions on Fedora
Fedora uses the alternatives system to decide which installed runtime and compiler back /usr/bin/java and /usr/bin/javac. When several JDKs are installed, switch both tools together so the compiler and runtime stay aligned.
List Installed OpenJDK Alternatives on Fedora
Run the interactive selector to see every installed Java runtime and the current default:
sudo alternatives --config java
There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/java-25-openjdk/bin/java 2 /usr/lib/jvm/java-latest-openjdk/bin/java Enter to keep the current selection[+], or type selection number:
The *+ marker shows the active automatic choice. If you only installed one runtime, the selector shows a single entry instead of two.
Switch the OpenJDK Compiler on Fedora
Run the matching selector for javac right after switching java. This matters because javac only exists in the -devel packages, and Fedora can leave the compiler on a different major than the runtime if you mix package types.
sudo alternatives --config javac
Relevant output includes:
There are 2 programs which provide 'javac'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/java-latest-openjdk/bin/javac *+ 2 /usr/lib/jvm/java-25-openjdk/bin/javac
Select the same major in both menus. If java --version says 26 but javac --version says 25, this selector is the fix.
Set a Specific OpenJDK Version on Fedora
Use the direct --set form when you already know which major you want and do not need the interactive menu. Run only the pair that matches your target version.
# OpenJDK 25
sudo alternatives --set java /usr/lib/jvm/java-25-openjdk/bin/java
sudo alternatives --set javac /usr/lib/jvm/java-25-openjdk/bin/javac
# java-latest-openjdk, currently OpenJDK 26 on Fedora 44
sudo alternatives --set java /usr/lib/jvm/java-latest-openjdk/bin/java
sudo alternatives --set javac /usr/lib/jvm/java-latest-openjdk/bin/javac
Check the active runtime and compiler after switching:
java --version
javac --version
Relevant output after each switch includes:
# OpenJDK 25 openjdk 25.0.3 2026-04-21 OpenJDK Runtime Environment (Red_Hat-25.0.3.0.9-1) (build 25.0.3+9) OpenJDK 64-Bit Server VM (Red_Hat-25.0.3.0.9-1) (build 25.0.3+9, mixed mode, sharing) javac 25.0.3 # java-latest-openjdk openjdk 26.0.1 2026-04-21 OpenJDK Runtime Environment (Red_Hat-26.0.1.0.8-1) (build 26.0.1+8) OpenJDK 64-Bit Server VM (Red_Hat-26.0.1.0.8-1) (build 26.0.1+8, mixed mode, sharing) javac 26.0.1
Return to Fedora’s Automatic OpenJDK Selection
Switch back to Fedora’s automatic priority rules when you no longer want a manual override.
sudo alternatives --auto java
sudo alternatives --auto javac
java --version
javac --version
openjdk 25.0.3 2026-04-21 OpenJDK Runtime Environment (Red_Hat-25.0.3.0.9-1) (build 25.0.3+9) OpenJDK 64-Bit Server VM (Red_Hat-25.0.3.0.9-1) (build 25.0.3+9, mixed mode, sharing) javac 25.0.3
Get Started with OpenJDK on Fedora
Once the right Java version is active, confirm that the toolchain can compile and run code instead of stopping at package installation.
Compile and Run a Test Program with OpenJDK on Fedora
Create a small Java source file first. Save it as HelloFedora.java in your current directory.
public class HelloFedora {
public static void main(String[] args) {
System.out.println("Hello from Fedora OpenJDK " + System.getProperty("java.version"));
}
}
Compile the file with javac, then run it with java:
javac HelloFedora.java
java HelloFedora
Hello from Fedora OpenJDK 25.0.3
If you switched to OpenJDK 26 first, the printed version changes to match that runtime. After this test, use the selected compiler for local builds or move into build automation with install Apache Maven on Fedora.
Find the Active OpenJDK Path on Fedora
Use the resolved java binary to locate the currently active JDK directory. This resolved path is what build tools usually want for JAVA_HOME.
dirname "$(dirname "$(readlink -f "$(command -v java)")")"
/usr/lib/jvm/java-25-openjdk
If Maven, Gradle, an IDE, or an application server complains about JAVA_HOME, follow the guide to set Java environment path in Fedora instead of hardcoding a stale directory by hand.
Troubleshoot OpenJDK Issues on Fedora
Most Fedora OpenJDK problems come down to the wrong package type, the wrong active alternative, a missing package branch, or a missing environment variable.
Fix javac Command Not Found on Fedora
If the shell returns javac: command not found, you installed a runtime-only package instead of the full development kit.
sudo dnf install java-25-openjdk-devel -y
javac --version
javac 25.0.3
Use java-latest-openjdk-devel instead when you intentionally installed the feature-release track.
Fix the Wrong OpenJDK Version on Fedora
If java --version reports the wrong major after installation, another runtime still owns the active alternatives entry.
sudo alternatives --config java
sudo alternatives --config javac
java --version
javac --version
Select the same major in both selectors, then recheck the runtime and compiler versions. This is especially important when OpenJDK 25 and java-latest-openjdk are installed together.
Fix Missing Java 21 Packages on Fedora 44
If DNF cannot find java-21-openjdk-devel on Fedora 44, the package is missing from the enabled Fedora repositories, not just disabled locally. Older Fedora 43-era commands fail with this boundary:
sudo dnf install java-21-openjdk-devel -y
Failed to resolve the transaction: No match for argument: java-21-openjdk-devel
Confirm the repository state with a quiet package query before troubleshooting mirrors or cache state:
dnf -q repoquery --available java-21-openjdk-devel
No output means the package is not available from the current Fedora repositories. Choose a verified Java 21 source rather than forcing DNF to skip the unavailable package.
Fix JAVA_HOME Errors on Fedora
Build tools that fail with JAVA_HOME is not set or JAVA_HOME is not defined correctly need the active JDK path exported into your shell or service environment.
dirname "$(dirname "$(readlink -f "$(command -v java)")")"
Use that path in your shell profile or follow the full steps to set Java environment path in Fedora when you want a persistent JAVA_HOME configuration.
Update or Remove OpenJDK on Fedora
Update OpenJDK Packages on Fedora
Fedora updates installed OpenJDK packages through the normal DNF workflow, so you do not need a separate repository or vendor updater for the Fedora package method.
sudo dnf upgrade --refresh -y
Recheck java --version after the upgrade if you want to confirm which major is currently active.
Remove OpenJDK Packages on Fedora
Remove the package track you no longer need by targeting its package names directly. This example removes the feature-release track and leaves Fedora’s default OpenJDK 25 line alone.
sudo dnf remove java-latest-openjdk-devel java-latest-openjdk java-latest-openjdk-headless -y
Use the matching java-25-openjdk-devel, java-25-openjdk, and java-25-openjdk-headless package names only when you deliberately want to remove Fedora’s default Java line. Verify the feature-release removal with RPM:
rpm -q java-latest-openjdk-devel java-latest-openjdk java-latest-openjdk-headless
package java-latest-openjdk-devel is not installed package java-latest-openjdk is not installed package java-latest-openjdk-headless is not installed
Conclusion
OpenJDK is installed on Fedora with a verified runtime, matching compiler, and a clear alternatives path for switching between Java 25 and the moving feature-release package. Keep Java 21 projects on a separately verified source, and recheck java --version and javac --version after package updates when multiple JDKs are present.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>