How to set JAVA Path in Linux machine

Run below command to install JAVA

yum install java-1.8*

Once the installation is completed, run below command to check JAVA Version.

java -version

Above command should give you the following result.

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

Run below command to find the JAVA path.

find /usr/lib/jvm/java-1.8* | head -n 3

Above command should give you the following results.


Use last path from above result to update the bash profile.

To update the bash profile run below command.

vi .bash_profile

Update bash_profile as below.

JAVA_HOME = /usr/lib/jvm/java-1.8.0-openjdk-

Save and Exit the bash_profile.

Refresh the bash profile using the below command.

source ~/.bash_profile

After refresh, run the following command to verify the JAVA path.


Output of the above command should be: