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 datacenters, 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 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)
Java is installed successfully

Leave a Reply

Your email address will not be published. Required fields are marked *


The maximum upload file size: 64 MB.
You can upload: image, audio, video, document, spreadsheet, interactive, text, archive, code, other.