Installing Java in RHEL 7

To install Java in Redhat Enterprise Linux follow these steps:

  • we are installing from OpenJDK rpm with command line

Run the following command to install the developer version of OpenJDK

# yum install java-1.7.0-openjdk-devel
  • (Optional) It is sometimes required to set the JAVA_HOME path variable.

You can know the java path by


It will give the path where Java is

In my case it was something like :


remember it might be different in your case.


in .bashrc file which is in home directory lets add the java home path as:

I am editing the file in vim editor

[lx@localhost ~]$ vi .bashrc

at the bottom of file add the java path in following format:

export JAVA_HOME="/path/to/java/home"

in my case, I added:

#java home path
export JAVA_HOME="/usr/lib/jvm/jre-1.8.0-openjdk/bin/java"

Your Gift of $200 Cloud Hosting Credit is Here. Claim Now!

To save first press Ctrl+ O and then


semicolon and then w and q and press enter.

You are done!

You can check the java version installed with:

java -version

My output was:

java version "1.7.0_141"
OpenJDK Runtime Environment (rhel- u141-b02)
OpenJDK 64-Bit Server VM (build 24.141-b02, mixed mode)

You can get full documentation here

Before you go, let's stay connected
About the Author
Lakshman Basnet
Nepali Digital Media Marketer currently based in Adelaide, South Australia who apart from playing with his cat - Eleven, also enjoys developing web content, publishing blogs and YouTube videos in his free time.

Leave a Comment