Menu
User

DropVPS Team

Writer: John hens

how to install java on centos 9

how to install java on centos 9

Publication Date

09/17/2025

Category

Articles

Reading Time

2 Min

Table of Contents

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

 

Linux VPS
U
Loading...

Related Posts