[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedFebruary 3, 2023

How to install java on CentOs.

How to Install Java on CentOS

OpenJDK is the open-source Java implementation packaged in the CentOS repositories, so installing it needs no third-party repo. This guide covers CentOS 7 (yum) and CentOS 8 / Stream (dnf) — the package names are identical, only the package manager differs.

Step 1: Update the package index

Refresh the repository metadata so you install the current build:

sudo yum update -y

On CentOS 8 or Stream, use dnf instead:

sudo dnf update -y

Step 2: Install the OpenJDK runtime

The runtime (JRE) is enough to run Java applications. Java 11 is the long-term support release available on CentOS:

sudo yum install java-11-openjdk -y

If your application needs Java 8, install java-1.8.0-openjdk instead. To see everything available:

yum search openjdk

Step 3: Install the development package

If you intend to compile Java rather than only run it, you also need the JDK, which provides javac:

sudo yum install java-11-openjdk-devel -y

Step 4: Confirm the packages are installed

Ask the RPM database what landed:

rpm -qa | grep openjdk

You should see both the runtime and, if you installed it, the -devel package listed.

Step 5: Check the Java version

java -version

The output confirms the active runtime:

openjdk version "11.0.21" 2023-10-17 LTS
OpenJDK Runtime Environment (build 11.0.21+9-LTS)
OpenJDK 64-Bit Server VM (build 11.0.21+9-LTS, mixed mode, sharing)

If you installed the devel package, check the compiler too:

javac -version

Setting JAVA_HOME

Many applications — Tomcat, Maven, Elasticsearch — expect JAVA_HOME to be set. Find the install path, then export it:

sudo update-alternatives --config java

Take the path shown, drop the trailing /bin/java, and add it to your profile so it survives a reboot:

echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk' | sudo tee -a /etc/profile.d/java.sh
source /etc/profile.d/java.sh
echo $JAVA_HOME

Running more than one Java version

You can install several JDKs side by side and switch the system default with the alternatives system:

sudo alternatives --config java

Pick the number for the version you want. Run the same command with --config javac to switch the compiler independently of the runtime.

That is the whole install: update, install the runtime, add the JDK if you compile, verify, and point JAVA_HOME at it.

Keep reading
How to use tmux & how to understand tmux.
July 8, 2023

How to use tmux & how to understand tmux.

How To Use Tmux & How To Understand Tmux. Tmux is a terminal multiplexer an alternative to GNU Screen . In other words, it means that you can start a Tmux session and then open multiple windows inside that session. Each window occupies the entire screen and can be split into rectangular panes.…

Read article
How to use curl command.
July 3, 2023

How to use curl command.

How To Use Curl Command. In this tutorial, we will show you how to use the curl tool through practical examples and detailed explanations of the most common curl options. Installing Curl. The curl package is pre-installed on most Linux distributions today. If curl is not installed you can easily…

Read article
How to Check your CentOS Version.
July 3, 2023

How to Check your CentOS Version.

How To Check Your CentOS Version. In this tutorial, we’ll show several different commands on how to check what version of CentOS is installed on your system. Check CentOS version from the Command Line. The lsb_release command displays Linux Standard Base (LSB) information about your Linux…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00