How To Install Java On CentOS 7

Java is a general purpose, high-level programming language developed by Sun Microsystems in 1995. Lots of application and websites that will not work unless you have Java installed. Java is fast, secure, and reliable.

In this article I will guide you how you can install the Java on CentOS 7 machine.

Install Java

You can install the latest Open JDK Runtime Environment 1.8.0 using YUM command.

$ sudo yum install java-1.8.0-openjdk.x86_64

After the installation, confirm it by using the following command:

$ java -version

You will get some output like below. Above command will tell you about the Java runtime environment that you have installed.

openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

In order to help Java-based applications locate the Java virtual machine properly, you need to set two environment variables:


$ sudo cp /etc/profile /etc/profile_backup
$ echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
$ echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
$ source /etc/profile

That’s it, now you can print them for review:

$ echo $JAVA_HOME
$ echo $JRE_HOME


Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author


Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment