how to install java on centos 9

Java is a widely used programming language and runtime environment, essential for running many applications and development tools. On CentOS 9, installing Java is straightforward using the default package manager.

Step 1: Update System Packages

Before installing new software, it’s always a good practice to update your system repositories:

sudo dnf update -y

Step 2: Install OpenJDK

CentOS 9 includes OpenJDK in its repositories. The recommended long-term support version is OpenJDK 17. Install it along with development tools:

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

Step 3: Verify the Installation

Check the installed version of Java to confirm the installation was successful:

java -version

You should see output similar to:

openjdk version "17.0.x" 2023-xx-xx
OpenJDK Runtime Environment ...
OpenJDK 64-Bit Server VM ...

Step 4: Switch Between Multiple Versions

If you install more than one version of Java, you can select the default version with the alternatives tool:

sudo alternatives --config java

Step 5 (Optional): Configure JAVA_HOME

Some applications require JAVA_HOME. First, find the Java installation path, then export it.

sudo alternatives --config java

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk

 

Share:

More Posts

How to Install Maven on macOS 2025

What you will read?1 Check for Java Installation2 Install Homebrew (If Not Installed)3 Install Maven via Homebrew4 Verify Environment Variables (Optional)5 Create a Sample Maven

How to Use Google SMTP Server

What you will read?1 Step 1: Enable SMTP Access in Gmail2 Step 2: Secure Connection with TLS3 Step 3: Send an Email via SMTP4 Step

how to install wine on RHEL

What you will read?1 Check RHEL version and CPU architecture2 Update system and install base tools3 Verify subscription and enable CodeReady Builder4 Enable EPEL repository5

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments