
Java runs more infrastructure than most people realize. It powers Android apps, enterprise backends, build pipelines with Maven and Gradle, CI/CD runners, and application servers like WildFly and Tomcat. If you need to install OpenJDK on Fedora 43, you are in the right place. This guide walks you through every step: choosing the right package, installing OpenJDK 21 or 25, managing multiple Java versions with the alternatives system, configuring JAVA_HOME, and fixing the most common issues that come up along the way.
Fedora 43 ships with native OpenJDK packages directly in its DNF repositories. You do not need to add third-party repos, download anything manually, or accept a vendor license. Red Hat actively maintains and tests these packages for the Red Hat family of distributions, which means you get security patches through standard sudo dnf upgrade runs — no separate updater needed.
This guide was tested directly on a Fedora 43 x86_64 workstation using the official Fedora DNF repositories. Every command shown here reflects what you will actually see on a real Fedora 43 install.
Prerequisites
Before starting, confirm your system meets these requirements:
- Fedora 43 Workstation or Server edition installed (x86_64)
- An active internet connection for DNF to download packages
- A user account with
sudoprivileges (must be a member of thewheelgroup) - At least 500 MB of free disk space for a full JDK install
- Terminal access (GNOME Terminal, Konsole, or an SSH session)
Check your group membership with:
groups
If wheel appears in the output, your account has sudo access and you are ready to proceed.
Also check whether Java is already installed:
java --version
If the command returns a version string, note the version and decide whether you need a different one. If it returns command not found, continue with Step 1 below.
What Is OpenJDK and Why Use It on Fedora 43
OpenJDK is the open-source, GPL-licensed reference implementation of the Java Platform, Standard Edition. It is the correct choice for Fedora users for a few practical reasons.
It integrates directly with DNF, updates automatically with your system, requires no Oracle account, and carries no licensing restrictions. Oracle JDK exists as an alternative, but it requires manual download, manual updates, and acceptance of a license agreement. Unless you need Oracle certification for a specific enterprise use case, OpenJDK handles every real-world scenario.
Red Hat and the Fedora Project maintain the OpenJDK packages in the Fedora repos. That gives them authority on this platform that a third-party or manually installed JDK simply does not have.
JRE vs. JDK: Which Package Do You Actually Need
Fedora 43 offers three package flavors for each Java version, and choosing the wrong one is a common source of confusion.
java-25-openjdk(JRE): Runtime only. Runs compiled Java applications but includes no compiler. Use this when your system only needs to launch Java apps.java-25-openjdk-devel(JDK): Runtime plusjavac,jar,javadoc, andjdb. Use this for any development or compilation work.java-25-openjdk-headless: Runtime without GUI libraries. The right choice for servers, containers, and CI runners where a display stack is a waste of disk space.
The rule is simple: if you are writing or compiling Java code, always install the -devel package. It automatically pulls in the matching runtime, so you never need to install both separately.
OpenJDK Versions Available on Fedora 43
Fedora 43 repositories carry three distinct Java tracks:
| Track | Package | Version on Fedora 43 | Use When |
|---|---|---|---|
| OpenJDK 25 LTS | java-25-openjdk-devel |
25.0.x | Default; new development work |
| OpenJDK 21 LTS | java-21-openjdk-devel |
21.0.x | Frameworks or CI pipelines pinned to Java 21 |
| java-latest | java-latest-openjdk-devel |
26.0.x | Testing new Java features; not for production |
A few important notes:
java-latest-openjdkcurrently maps to OpenJDK 26 on Fedora 43 and follows the rolling feature track. It does NOT stay pinned to an LTS branch and will change major versions over time.- OpenJDK 21 is available in Fedora 43 and 44 but will be removed starting with Fedora 45. Plan your migration to Java 25 before then.
- For greenfield projects, pick Java 25. For existing codebases targeting Java 21, stay there until you are ready to migrate.
Step 1: Update Fedora 43 Before Installing OpenJDK
Always update your system before installing new packages. Stale DNF metadata can cause dependency conflicts or pull an outdated package version.
sudo dnf upgrade --refresh -y
The --refresh flag forces DNF to sync metadata from all enabled repositories. The -y flag skips the confirmation prompt automatically.
Expected output ends with:
Complete!
This step also applies any pending security patches, which is good practice before adding new software.
Step 2: Search Available OpenJDK Packages on Fedora 43
Before you install anything, query the repos to see exactly what is available on your system:
dnf search openjdk
The output lists all matching packages, including java-21-openjdk, java-25-openjdk, java-latest-openjdk, and their -devel and -headless variants.
If you want to narrow results to a specific version:
dnf search java-25
This step helps you confirm the correct package name before running the install command. Package names on Fedora follow the pattern java-[version]-openjdk[-devel|-headless]. Do not use Ubuntu or Debian names like openjdk-25-jdk here — they will not resolve.
Step 3: Install OpenJDK on Fedora 43
Now it is time to actually install OpenJDK. This section covers all three available tracks.
Install OpenJDK 25 (Recommended)
OpenJDK 25 is Fedora 43’s current default LTS and the best starting point for most new projects:
sudo dnf install java-25-openjdk-devel -y
For runtime only:
sudo dnf install java-25-openjdk -y
For headless servers or containers:
sudo dnf install java-25-openjdk-headless -y
Confirm the package is installed with RPM:
rpm -q java-25-openjdk-devel
Expected output:
java-25-openjdk-devel-25.0.2.0.10-5.fc43.x86_64
DNF resolves all dependencies automatically. You do not need to install the runtime separately when you use -devel.
Install OpenJDK 21
Choose OpenJDK 21 when your framework, vendor certification, or CI pipeline is pinned to that LTS release:
sudo dnf install java-21-openjdk-devel -y
For runtime only:
sudo dnf install java-21-openjdk -y
For headless environments:
sudo dnf install java-21-openjdk-headless -y
Verify with RPM:
rpm -q java-21-openjdk-devel
Expected output:
java-21-openjdk-devel-21.0.10.0.7-2.fc43.x86_64
Keep the Fedora lifecycle warning in mind here: Java 21 packages disappear from Fedora 45 repos, so schedule your migration before then.
Install java-latest-openjdk
This track follows the rolling feature release, not an LTS branch. On Fedora 43, it currently maps to OpenJDK 26. Use it only for testing new Java language features:
sudo dnf install java-latest-openjdk-devel -y
Verify:
rpm -q java-latest-openjdk-devel
Expected output:
java-latest-openjdk-devel-26.0.0.0.35-0.1.fc43.x86_64
Fedora assigns java-latest-openjdk a very low alternatives priority. Installing it does NOT automatically make it the active java command when OpenJDK 25 is also present. You have to set it manually if you want to use it (see Step 5 below).
Step 4: Verify the OpenJDK Installation on Fedora 43
Do not stop at just running java --version. Run all three of these checks to confirm a complete, working toolchain.
Check the runtime version:
java --version
Expected output after installing OpenJDK 25:
openjdk 25.0.2 2026-01-20
OpenJDK Runtime Environment (Red_Hat-25.0.2.0.10-3) (build 25.0.2+10)
OpenJDK 64-Bit Server VM (Red_Hat-25.0.2.0.10-3) (build 25.0.2+10, mixed mode, sharing)
Check the compiler version:
javac --version
Expected output:
javac 25.0.2
Confirm binary locations:
which java
which javac
Both should return paths under /usr/bin/. If javac returns command not found here, you installed a runtime-only package — install the -devel version instead (see Troubleshooting below).
Step 5: Manage Multiple OpenJDK Versions with Alternatives
Fedora’s alternatives system manages symbolic links in /usr/bin/ pointing to specific JDK installations in /usr/lib/jvm/. Multiple JDKs can coexist cleanly without conflict.
Each installed JDK registers with alternatives during DNF install and receives a priority value. The highest priority becomes the system default unless you override it manually.
List All Installed Java Runtimes
Run the interactive selector to see every registered runtime:
sudo alternatives --config java
With all three versions installed, the output looks like this:
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/java-25-openjdk/bin/java
2 /usr/lib/jvm/java-21-openjdk/bin/java
3 /usr/lib/jvm/java-latest-openjdk/bin/java
Enter to keep the current selection[+], or type selection number:
The *+ marker shows the current active automatic choice. Type a selection number and press Enter to change it.
Switch the Compiler Too
Always run this command right after switching java. The javac binary only exists in -devel packages, and it can fall out of sync with the runtime if you mix package types:
sudo alternatives --config javac
Select the same major version you chose for java. If java --version says 25 but javac --version says 21, this command is the fix.
Non-Interactive Version Switch
Use --set when you want to skip the menu, such as in a script or Ansible playbook:
# Switch to 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
# Switch to OpenJDK 21
sudo alternatives --set java /usr/lib/jvm/java-21-openjdk/bin/java
sudo alternatives --set javac /usr/lib/jvm/java-21-openjdk/bin/javac
Verify after switching:
java --version
javac --version
Both should report the same major version. To undo a manual override and let Fedora’s automatic priority rules take over again:
sudo alternatives --auto java
sudo alternatives --auto javac
Step 6: Set JAVA_HOME on Fedora 43
JAVA_HOME is not required for basic command-line use, but tools like Maven, Gradle, IntelliJ IDEA, Eclipse, and application servers like Tomcat and WildFly expect it to be set.
First, find the correct path for the currently active JDK automatically. Do not hardcode a path:
dirname $(dirname $(readlink -f $(which java)))
Expected output:
/usr/lib/jvm/java-25-openjdk
To set JAVA_HOME persistently for your current user, add the export to your shell profile:
echo 'export JAVA_HOME=/usr/lib/jvm/java-25-openjdk' >> ~/.bashrc
source ~/.bashrc
To set it system-wide, create a dedicated profile script:
sudo nano /etc/profile.d/java.sh
Add this line, then save:
export JAVA_HOME=/usr/lib/jvm/java-25-openjdk
Reload with source /etc/profile or open a new terminal session. Verify it is set:
echo $JAVA_HOME
Step 7: Test Your OpenJDK Setup with a Real Java Program
Package installation does not guarantee a working toolchain. Compiling and running actual code is the only real confirmation.
Create a test file:
nano HelloFedora.java
Add this code (the class name must match the filename exactly — this is a Java requirement):
public class HelloFedora {
public static void main(String[] args) {
System.out.println("Hello from Fedora OpenJDK " + System.getProperty("java.version"));
}
}
Compile the file:
javac HelloFedora.java
Successful compilation produces no output but creates a HelloFedora.class file in the same directory. Now run it:
java HelloFedora
Expected output:
Hello from Fedora OpenJDK 25.0.2
Java 11 and later also support single-file execution without an explicit compile step:
java HelloFedora.java
If you see the version printed, your complete OpenJDK setup on Fedora 43 is fully operational.
How to Update OpenJDK on Fedora 43
OpenJDK updates flow through standard Fedora system updates. You need no separate repo, vendor updater, or manual download process.
sudo dnf upgrade --refresh -y
After the upgrade, verify the updated version:
java --version
Critical security updates for OpenJDK 25 and 21 on Fedora 43 were delivered this way in January 2026. Staying current with dnf upgrade is the best defense against Java CVEs.
How to Remove OpenJDK from Fedora 43
First, list everything currently installed:
dnf list installed | grep java
Remove a specific version by targeting all three of its package names:
sudo dnf remove java-21-openjdk-devel java-21-openjdk java-21-openjdk-headless -y
Confirm the removal with RPM:
rpm -q java-21-openjdk-devel java-21-openjdk java-21-openjdk-headless
All three should return package [name] is not installed. Avoid using wildcards like java-* carelessly — that removes every Java package on the system at once, which can break build tools and IDEs without warning.
Troubleshooting Common OpenJDK Issues on Fedora 43
javac: command not found
Cause: You installed a runtime-only package (java-25-openjdk) instead of the development kit.
Fix:
sudo dnf install java-25-openjdk-devel -y
javac --version
Expected output after the fix: javac 25.0.2. Swap 25 for 21 or latest if you are targeting a different track.
Wrong Java Version Is Active After Install
Cause: Another JDK with higher alternatives priority is still set as the system default.
Fix:
sudo alternatives --config java
sudo alternatives --config javac
java --version
javac --version
Select the same major version in both selectors, then confirm with the version commands.
JAVA_HOME is not set Error from Maven or Gradle
Cause: Build tools need an explicit JDK path that environment variables have not provided.
Fix: Run the resolver to get the correct path, then export it:
dirname $(dirname $(readlink -f $(which java)))
Use that output as your JAVA_HOME value in ~/.bashrc or /etc/profile.d/java.sh.
javac and java Report Different Major Versions
Cause: java and javac point to different JDK installs through alternatives. This happens when you mix runtime-only and -devel packages across different versions.
Fix: Run both config commands and select matching majors in both:
sudo alternatives --config java
sudo alternatives --config javac
sudo dnf install Fails with “No match for argument”
Cause: Stale DNF metadata that does not reflect the current state of the Fedora repos.
Fix:
sudo dnf makecache
Then retry the original install command.
Congratulations! You have successfully installed OpenJDK. Thanks for using this tutorial for installing OpenJDK on Fedora 43 Linux system. For additional help or useful information, we recommend you check the official OpenJDK website.