Learn how to install Java on Rocky Linux 9 with our comprehensive step-by-step guide. Set up the Java Development Kit (JDK) and Runtime Environment (JRE) to start developing and running Java applications on your Linux system. #centlinux #linux #java
Table of Contents
What is Java?
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture.
The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub, particularly for client–server web applications, with a reported 9 million developers. (Source: Wikipedia)
Java was originally developed by James Gosling at Sun Microsystems. It was released in May 1995 as a core component of Sun Microsystems’ Java platform. The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun had relicensed most of its Java technologies under the GPL-2.0-only license. Oracle offers its own HotSpot Java Virtual Machine, however the official reference implementation is the OpenJDK JVM which is free open-source software and used by most developers and is the default JVM for almost all Linux distributions.
As of September 2022, Java 19 is the latest version, while Java 17, 11 and 8 are the current long-term support (LTS) versions.

Java vs Python
Java and Python are two of the most popular programming languages, each with its strengths and ideal use cases. Here’s a comparison of Java and Python across various dimensions:
Java
Pros
- Performance: Generally faster execution due to its statically-typed nature and Just-In-Time (JIT) compiler.
- Robustness: Strong type-checking at compile-time helps catch errors early.
- Scalability: Well-suited for large, complex, and high-performance applications, especially in enterprise environments.
- Platform Independence: Write Once, Run Anywhere (WORA) with the Java Virtual Machine (JVM).
- Rich Ecosystem: Extensive libraries, frameworks (like Spring, Hibernate), and tools.
Cons
- Verbosity: More boilerplate code required, which can make development slower and code harder to read.
- Learning Curve: Steeper learning curve due to its strict syntax and object-oriented principles.
Best for
- Enterprise-level applications.
- Android app development.
- Large-scale web applications.
- Financial services.
Python
Pros
- Simplicity: Simple and readable syntax, making it easy to learn and write.
- Rapid Development: Ideal for quick prototyping and development.
- Versatility: Wide range of applications, from web development to data science, AI, and scripting.
- Rich Ecosystem: Extensive libraries and frameworks (like Django, Flask, TensorFlow, Pandas).
- Community Support: Strong community and vast amount of resources for learning and troubleshooting.
Cons
- Performance: Generally slower execution compared to Java, as it is interpreted and dynamically typed.
- Less Strict: Dynamically-typed nature can lead to runtime errors that are harder to debug.
Best for
- Web development.
- Data science and machine learning.
- Automation and scripting.
- Prototyping and smaller projects.
Feature Comparison
| Feature | Java | Python |
|---|---|---|
| Typing | Statically-typed | Dynamically-typed |
| Performance | High | Moderate |
| Syntax | Verbose, strict | Concise, readable |
| Learning Curve | Steeper | Gentle |
| Development Speed | Moderate | Fast |
| Popular Frameworks | Spring, Hibernate, Struts | Django, Flask, TensorFlow |
| Use Cases | Enterprise apps, Android, large-scale systems | Web development, data science, automation |
Conclusion
- Choose Java if you need a language for developing large, performance-critical applications, particularly in enterprise settings or for Android development.
- Choose Python if you want a versatile, easy-to-learn language for rapid development, especially for web development, data science, machine learning, or automation tasks.
Both languages have their unique strengths and can often complement each other in a diverse technology stack.
Environment Specification
For this guide, we are working with a minimal installation of Rocky Linux 9, running on a virtual machine specifically configured to suit the needs of this tutorial. This setup ensures a streamlined environment with only the essential components installed, minimizing unnecessary services and software. Below are the specifications of our Rocky Linux 9 virtual machine:
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – Rocky Linux release 9.0 (Blue Onyx)
- Hostname – java-01.centlinux.com
- IP Address – 192.168.116.130/24
For this tutorial, you will need a reliable environment to install and run Java on Rocky Linux 9. Whether you prefer a physical device or a cloud-based server, using a Mini PC or a VPS can provide a perfect Home Lab setup for experimenting with Linux servers. A compact Mini PC offers the advantage of a dedicated, low-power machine that you can easily manage and customize.
[Grab a Mini PC for your Home Lab – Shop with Us!]
While a Bluehost VPS gives you the flexibility of scalable cloud resources with easy remote access.
[Try Bluehost VPS Now – Perfect for Linux & DevOps Enthusiasts!]
Both options are excellent for learning server administration and running Java applications smoothly. If you’re interested, you can check out the recommended Mini PCs and Bluehost VPS plans through the affiliate links above to support the blog at no extra cost to you.
Disclaimer: This post contains affiliate links. If you purchase through these links, I may earn a small commission at no additional cost to you, which helps support ongoing content creation and tutorial development.
Update Linux Operating System
By following the best practice, update your Linux operating system before installing Java 19 software.
Login as root user on your Linux server by using a ssh client.
Refresh your yum cache as follows.
dnf makecacheUpdate software packages in your Linux operating system.
dnf update -yIf the above command update your Linux Kernel then, you should reboot your operating system with new Kernel before installing Java 19 software.
rebootCheck the Linux operating system and Kernel versions as follows.
cat /etc/rocky-release
uname -rOutput:
Rocky Linux release 9.0 (Blue Onyx)
5.14.0-70.26.1.el9_0.x86_64
PDF Reader – PDF Viewer For Kindle Fire Tablet
$2.99 (as of October 30, 2025 20:23 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Install Java on Rocky Linux 9
Java 19, the latest release of the Java programming language at the time of this writing, is readily available for download from Oracle’s official website. This version includes cutting-edge features and improvements designed to enhance performance, security, and developer productivity.
To obtain Java 19, navigate to the Oracle Java Downloads page. There, you can find the appropriate installer or archive tailored to your operating system and architecture, including options for Linux, Windows, and macOS. Oracle also provides detailed release notes, documentation, and support resources to guide you through the installation and setup process.
Downloading directly from Oracle ensures that you receive the official, up-to-date version of the software, free from modifications or potential security risks. Make sure to review Oracle’s licensing terms to confirm your use case aligns with their distribution policies. For enterprise environments or production servers, consider enabling updates and patches to keep your Java installation secure and efficient.

Copy the URL according to your preferred platform and then you can use wget command to download the Java 19 software directly from Linux commandline.
But first, use following command to install wget utility, if it isn’t already installed on your Linux machine.
dnf install -y wgetNow, by using following commands, download Java 19 RPM into /tmp directory.
cd /tmp
wget https://download.oracle.com/java/19/latest/jdk-19_linux-x64_bin.rpmAfter successful download, you can invoke dnf command to install Java 19 on Rocky Linux 9.
dnf install -y jdk-19_linux-x64_bin.rpmTo verify Java 19 installation, execute java command to check the version of active Java software. (Note: You can run multiple versions of Java on a Single Linux operating system with the help of alternatives command.)
java --versionOutput:
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
Java 19 has been successfully installed on your Rocky Linux 9 system. To ensure seamless operation and compatibility for Java-based applications, it is recommended to set the necessary Java environment variables. These variables include JAVA_HOME, which points to the Java installation directory, and PATH, which allows Java commands to be executed from any location in the terminal. Configuring these environment variables ensures that your system correctly identifies the Java version and location, providing a consistent runtime environment for your applications.
cat << EOF > /etc/profile.d/java.sh
export JAVA_HOME=/usr/lib/jvm/jdk-19-oracle-x64
export PATH=$PATH:$JAVA_HOME/bin
EOFVideo Tutorial
If you prefer a step-by-step visual guide, we’ve also created a detailed video tutorial on “How to Install Java on Rocky Linux 9.” The video walks you through every step of the installation process, from updating your system to verifying your Java version. It’s perfect for users who like to follow along visually or need additional clarity on any of the steps mentioned in this guide. Be sure to check it out for a more interactive learning experience!
Frequently Asked Questions (FAQs)
Here are 5 beginner-friendly FAQs related to Java with short answers:
1. What is Java?
Java is a popular, object-oriented programming language known for its “Write Once, Run Anywhere” capability, meaning compiled Java code can run on any platform with a Java Virtual Machine (JVM).
2. How do I install Java?
Download and install the Java Development Kit (JDK) from Oracle’s website or use an OpenJDK distribution. Then, set the JAVA_HOME environment variable.
3. What is the difference between JDK, JRE, and JVM?
- JVM (Java Virtual Machine) – Runs compiled Java bytecode.
- JRE (Java Runtime Environment) – Includes JVM + libraries to run Java programs.
- JDK (Java Development Kit) – Includes JRE + tools (compiler, debugger) to develop Java applications.
4. How do I write my first Java program?
Create a file named HelloWorld.java with:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}Compile with javac HelloWorld.java and run with java HelloWorld.
5. What are the main features of Java?
- Platform-independent (thanks to JVM)
- Object-oriented (classes, inheritance, polymorphism)
- Automatic memory management (garbage collection)
- Strongly typed (strict variable type rules)
Final Thoughts
Congratulations on successfully learning how to install Java on Rocky Linux 9! With Java set up, you can now develop and run Java applications efficiently. Whether you’re working on development projects, running Java-based software, or learning Java programming, having a properly configured Java environment on your system will greatly enhance your productivity.
Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me today!
What’s Next
If you’re serious about mastering Java in 2025, the Java Masterclass 2025: 130+ Hours of Expert Lessons by Tim Buchalka, Edwin Einsen, and Igor Popovic is a must-have resource. This comprehensive course takes you from beginner to advanced concepts with real-world coding exercises, practical projects, and deep insights from industry experts.
Whether you’re preparing for a programming career, upgrading your skills for the job market, or simply passionate about software development, this course offers everything you need in one place. Don’t miss out on the chance to future-proof your skills and stay ahead in the ever-evolving world of Java.
Disclaimer: This post contains affiliate links. If you purchase through these links, I may earn a small commission at no extra cost to you, which helps support the site and keeps valuable content coming your way.


Leave a Reply
Please log in to post a comment.