Java (JDK 8) Installation on CentOS 7

Bayu Adi Wibowo
2 min readDec 18, 2023

--

Introduction

Java is a programming language and computing platform first released by Sun Microsystems in 1995. There are lots of applications and websites that will not work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to data centers, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
(Reference: https://www.oracle.com/java/)

Many packages, tools, and services on CentOS need Java for running the binary file. In this post, I will share how to install JDK 8 on CentOS 7.

Installation

Download JDK package

Go to this site to download the .rpm file installer SITE. Then download the jdk-8u101-linux-x64.rpm file and put it to the server or your machine.

Install JDK package

To install the JDK package, go to the directory where you put the .rpm file, then follow the command below. You must log in as a root user.

[root@server ~]# rpm -Uvh jdk-8u101-linux-x64.rpm
[root@server ~]# alternatives --set java /usr/java/jdk1.8.0_101/jre/bin/java
[root@server ~]# sed -i '$ a export JAVA_HOME=/usr/java/jdk1.8.0_101' /root/.bash_profile
[root@server ~]# sed -i '$ a export PATH=$PATH:$JAVA_HOME/bin' /root/.bash_profile
[root@server ~]# sed -i '$ a export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar' /root/.bash_profile
[root@server ~]# source /root/.bash_profile

Verify installed JDK version

[root@server ~]# java -version
java version “1.8.0_101”
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

--

--