How to Install Java on AlmaLinux 10: A Step-by-Step Guide

Learn how to install Java on AlmaLinux 10 using Alma’s repository or the Oracle version, and set up your environment variables.

AlmaLinux is a rock-solid, server-focused distribution from the enterprise Linux family—perfect for anyone who wants a stable, predictable platform they can count on. And while it’s built with servers in mind, it also works very well as a desktop system.

Now, if you’re a Java developer or just need a reliable environment to run your Java applications and have chosen Alma 10 for a platform, the first question you’re probably asking is: How do I install Java on AlmaLinux? Well, you’re in the right place.

In this guide, I’ll walk you through the process step by step. Additionally, we’ll also make sure your system is set up properly by covering how to configure the necessary environment variables so your Java installation is fully ready to go.

OpenJDK vs. Oracle JDK

Before we get started, I want to clear something up. In other guides, you might see instructions for installing the Oracle version of Java. But here, I’ve chosen not to cover that for a reason—and here’s why.

First and foremost, the version of Java available in the AlmaLinux 10 repositories is licensed under GPLv2, which means it’s completely free to use—even for commercial purposes.

Oracle’s version, on the other hand, is distributed under their No-Fee Terms and Conditions (NFTC). While that may seem straightforward at first glance, there are some hidden caveats in the license that developers and organizations should be aware of before using it in production.

First and foremost, no-fee is different from open source. I mean, Oracle JDK under NFTC is not open source, so you’re not allowed to modify or redistribute the source code. In AlmaLinux, you can use Java commercially, modify it, and redistribute original or modified builds.

With Oracle JDK, while it permits free internal and production use and redistribution of unmodified binaries, you can’t distribute modified builds, and the no-fee period is time-boxed per release line. So, in practice, Oracle implementation does not give you anything more – both share the same upstream, I mean, both are built from the OpenJDK code.

With that said, the choice is pretty clear: OpenJDK. Now that we’ve cleared that up, back to the main topic of this guide.

Choosing the Right Java Package in AlmaLinux 10

Before we jump into installing Java on AlmaLinux 10, there’s one more thing worth clearing up—picking the right OpenJDK package. The distro offers three main variants, so allow me to break down what each one does quickly. That way, you’ll know exactly which one makes the most sense for your needs.

OpenJDK package provided by AlmaLinux 10.
OpenJDK package provided by AlmaLinux 10.
  • java-21-openjdk (The Standard Runtime Environment): Provides the full Java runtime needed to run Java applications. So, if you want to run Java programs (including GUI-based apps) without doing any development, this is the way to go.
  • java-21-openjdk-headless (Minimal Runtime): A stripped-down runtime optimized for server or CLI environments. No GUI support — excludes AWT, Swing, and other X11 dependencies. It’s Ideal for environments where graphical components are unnecessary.
  • java-21-openjdk-devel (Development Tools): Provides the Java Development Kit (JDK) for compiling and building Java applications. If you plan to write, compile, or build Java applications rather than just run them, this is what you need.

Install Java on AlmaLinux 10

Based on all that, I’d suggest going with the “java-21-openjdk-devel” package as your all-in-one solution. Even if you’re not planning to compile Java apps yourself, it’s still handy to have that capability ready to go. Plenty of services compile Java code on the fly while doing their work, so having this package installed makes life easier for most Java setups.

Installing it couldn’t be easier. Just a single DNF command:

sudo dnf install java-21-openjdk-develCode language: Bash (bash)
Installing Java on AlmaLinux 10.
Installing Java on AlmaLinux 10.

As you can see, installing “java-21-openjdk-devel” also automatically pulls in “java-21-openjdk,” and that in turn pulls in “java-21-openjdk-headless” as a dependency. So you end up with a full Java suite installed on your AlmaLinux 10 system.

Once the packages are downloaded and installed, use the command provided below to verify that the installation was successful. It should output similar to the following:

java -version
Verify the Java installation.
Verify the Java installation.

And that’s all. We now have OpenJDK 21 successfully installed on our AlmaLinux 10 system.

Set JAVA_HOME Environment Variable

You can think of the “JAVA_HOME” environment variable as a “contract” in the Java ecosystem. It points to the root of a JDK/JRE directory. Why do we need it?

Various applications (for example, Maven, Gradle, Tomcat, Jenkins, and so on) use “JAVA_HOME” to locate the JDK installation directory. On top of that, many CI/CD pipelines, Docker images, and development environments also assume it is set. Without it, they might fail to start.

You can easily find the right path for the “JAVA_HOME” variable by running the command below:

readlink -f /usr/bin/java | sed "s:bin/java::"Code language: Bash (bash)
Finding the path for the "JAVA_HOME" variable.
Finding the path for the “JAVA_HOME” variable.

However, instead of going through the hassle of manually editing your “~/.bashrc” file to add the path—or temporarily exporting variables—here’s a simpler, automated way to make the change permanent. Execute the four lines below in the terminal:

sudo tee /etc/profile.d/java.sh > /dev/null <<'EOF'
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export PATH=$JAVA_HOME/bin:$PATH
EOFCode language: Bash (bash)

Finally, make the “java.sh” file we just created executable.

sudo chmod +x /etc/profile.d/java.shCode language: Bash (bash)
Setting up JAVA_HOME system-wide.
Setting up JAVA_HOME system-wide.

After logging out and back in, “JAVA_HOME” will always match the active Java version. A simple check:

echo $JAVA_HOMECode language: Bash (bash)
Verify that JAVA_HOME is set correctly.
Verify that JAVA_HOME is set correctly.

Uninstall Java on AlmaLinux 10

If, for some reason, you want to remove Java from your AlmaLinux 10 system, here’s how to approach it. First, use the command below to find out all locally installed Java packages.

rpm -aq | grep openjdkCode language: Bash (bash)
Finding the installed OpenJDK packages.
Finding the installed OpenJDK packages.

Then, just pass their names as arguments to the dnf remove command.

sudo dnf remove java-21-openjdk-headless java-21-openjdk java-21-openjdk-develCode language: Bash (bash)

And finally, make sure to delete the “java.sh” file you created earlier.”

sudo rm /etc/profile.d/java.shCode language: Bash (bash)

Conclusion

As you can see from this guide, installing Java on AlmaLinux 10 is simple and can be completed in minutes. Now, you are all set to run Java applications, develop Java programs, and enjoy the many benefits of this powerful programming language.

Thanks for your time! I hope you find this guide helpful. Your feedback and comments are most welcome.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Leave a Reply

Your email address will not be published. Required fields are marked *