Guides 11792 Published by

The article explains how to install Java 17 on Rocky Linux 8 or Alma Linux 8, beginning with a quick version check to make sure you don’t overwrite an existing JDK. It then walks through installing the `java‑17-openjdk-devel` package from AppStream using dnf, and shows how to set the new runtime as the system default via the alternatives mechanism. An optional section covers downloading Oracle’s RPM manually, installing it with rpm, and updating alternatives to switch between vendor implementations. Finally, the guide highlights common pitfalls such as mistyping the package name or neglecting to update alternatives, offering practical fixes so you can get Java 17 up in minutes.



Installing Java 17 on Rocky Linux 8 or Alma Linux 8 – Quick and Straight‑Forward

When you’re ready to run a modern Spring Boot app or test a new Kotlin project, Java 17 is the default choice. In this short guide you’ll get an OpenJDK 17 installation up and running in minutes, plus an optional Oracle JDK route if vendor‑specific features matter.

Step 1: See What You Already Have
java -version

If that prints something older than 17 (most of us still have Java 11 by default), you’ll need to add a new package. Knowing the current version helps avoid accidentally overwriting an existing setup.

Step 2: Grab OpenJDK 17 From AppStream

Rocky and Alma ship java‑17-openjdk in their main repositories, so no extra repo work is needed:

sudo dnf install java-17-openjdk-devel

The -devel variant installs the compiler (javac) as well as the runtime. The install step pulls dependencies automatically and verifies package signatures, which keeps your system secure.

Step 3: Make It the Default

If you have multiple JDKs installed, use Linux’s alternatives system to pick which one java and javac point at:

sudo alternatives --config java

A menu will appear. Enter the number next to Java 17. Repeat for javac if you need the compiler as default.

Verify everything is wired correctly:

java -version
javac -version

Both should now report 17.x. I’ve seen folks leave this step out, then run a Gradle build that silently used Java 11 and got cryptic “class file has wrong version” errors.

Step 4: (Optional) Install Oracle JDK 17

Some projects rely on Oracle’s JVM features or require the exact Oracle binaries for compatibility tests. You can fetch the RPM from Oracle’s website, but you’ll need to accept the license manually:

wget --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" \
     https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm

sudo rpm -ivh jdk-17_linux-x64_bin.rpm

After installation, update alternatives just like before:

sudo alternatives --install /usr/bin/java java /opt/jdk-17/bin/java 1700
sudo alternatives --config java   # pick Oracle if you prefer it

Oracle’s JDK can be a bit heavier, but if you’re running a legacy app that checks for the vendor string, this is your route.

Common Pitfalls (And What I’ve Seen)
  • Wrong package name: Typing java‑17-openjdk instead of java-17-openjdk-devel installs only the runtime, leaving you without javac.
  • Not updating alternatives: Some users install the new JDK but forget that java -version still shows the old one because the system’s symlink hasn’t changed.
  • Trying to use yum on Rocky/Alma: They’ve moved from yum to dnf, and while yum is an alias now, it can produce confusing output if the alias isn’t set up correctly.

Give this a whirl on a fresh VM or container; you’ll have Java 17 ready for your next project in less than five minutes. If anything goes sideways, drop a comment – I’ve seen a few hiccups that are easy to fix with a quick tweak.