Guides 11792 Published by

It shows how to get Java 17, 11, or the legacy 8 LTS on Fedora by pulling the right packages from the distro’s repos and a third‑party source. First you keep the OS current with `sudo dnf update && sudo dnf upgrade -y` and install `dnf-plugins-core`, then install OpenJDK 17 or 11 with simple `sudo dnf install -y java-17-openjdk-devel` (or java‑11) and verify with `java -version`. Because Fedora no longer ships JDK 8, the guide adds Temurin’s repository via an rpm URL before installing `temurin-8-jdk`, again checking the version afterward. Finally it explains how to switch between installed Java versions using the `alternatives` system and notes when keeping multiple JDKs is worth the extra disk space.



Install Java 17, 11, or 8 LTS on Fedora Linux

Want a rock‑solid JDK without wrestling with Windows‑style installers? On Fedora you can pull the long‑term‑support releases 17, 11, or even 8 with one line of code. I’ll show you how to install each, flip between them, and nip the “wrong java in $PATH” headache in the bud.

Step 1: Get your system ready
sudo dnf update && sudo dnf upgrade -y

Fedora’s default repos stay fresh only if you keep the base OS up to date. Skipping this step can leave you hunting a broken dependency later.

Also install dnf-plugins-core if it isn’t already—needed for repo management:

sudo dnf install -y dnf-plugins-core
Installing Java 17 from Fedora’s repos

Fedora 35+ ships OpenJDK‑17 in the standard mirror set.

sudo dnf install -y java-17-openjdk-devel

After installation, double‑check:

java -version
# output: openjdk version "17.0.x" (build x)

If you run into a “command not found” after the install, it’s usually because your $PATH still points to an older java. Run alternatives --config java and pick the new one.

Getting Java 11 on Fedora

Pretty much the same process:

sudo dnf install -y java-11-openjdk-devel

And verify:

java -version
# openjdk version "11.0.x" …

A quick note: many projects still target 11, and I’ve seen a few Spring Boot apps complain about “Unsupported major.minor version” if they accidentally point to Java 8. Keeping both side‑by‑side is handy for those cases.

Installing the long‑standing Java 8

Java 8 isn’t in the default repo on recent Fedora releases, so you need a third‑party source. The most battle‑tested is Temurin (formerly AdoptOpenJDK). Add their repo first:

sudo rpm -Uvh https://packages.adoptium.net/artifactory/rpm/temurin-release.repo

Now install the JDK:

sudo dnf install -y temurin-8-jdk

Check it out:

java -version
# openjdk version "1.8.x" …

I’ve had to do this after a Maven build pulled an old 7‑based dependency that only works on Java 8. The Temurin package is lightweight and stays in sync with the upstream OpenJDK.

Switching between JDKs with alternatives

Fedora uses the classic alternatives system to decide which java, javac, etc., you get when you type them. List available choices:

sudo alternatives --display java

Pick one interactively:

sudo alternatives --config java

Select the number that points at /usr/lib/jvm/java-17-openjdk or whatever your target is. Repeat for javac and any other tools you need.

Why you might not need all three

If you’re only ever running a single project, stick with one JDK version—no point bloating /usr/lib/jvm. But if you juggle legacy code, CI pipelines, or just love comparing compiler optimizations, having 8, 11, and 17 side‑by‑side is a lifesaver. The cost is just a few megabytes of disk space.

That’s all there is to it. Pick the LTS that fits your code, drop in the right repo, install a couple of packages, and let alternatives do its job.