Home » Java: Install JDK and set JAVA_HOME on Linux – CentOS 7

Java: Install JDK and set JAVA_HOME on Linux – CentOS 7

by Pring
Java: Install JDK and set JAVA_HOME on Linux - CentOS 7

This tutorial will teaches you how to install JDK and set JAVA_HOME on Linux – CentOS 7 system. JDK is means Java Development Kit.

I. Prerequisites.

1. Login to your system via SSH. You can use PuTTy tool or Poderosa tool,…
2. Login with root user.  If you are logged in as another user, you will need to add sudo before each command.

II. Install JDK on CentOS 7 by step by step.

To install JDK on Linux – CentOS 7. Follow these steps:

Step 1. Download Oracle Java JDK software.
Step 2. Set JAVA_HOME Environment variable.
Step 3. Verify the installation.

Similarly, you want to install java JDK and set JAVA_HOME on Windows. You can click here.

You can see details of Video on How to Install JDK on Linux – CentOS 7 as below.
[Sorry, the video we will update later]

Or you also can see details as below.

Step 1: Download Oracle Java JDK software.

1. Update all packages on your system including yum.
Enter the command below.

yum -y update

2. Install Java JDK 8.
Enter the command below:

yum install java-1.8.0-openjdk

Step 2: Set JAVA_HOME Environment variable.

1. Check and get path of Java installed on system.
You want to set default with command below.

sudo alternatives –config java

2. Set JAVA_HOME variable into .bash_profile or .bashrc file.
.bash_profile and .bashrc file is the user’s specific environment and startup programs.

You can find them at: /etc/profile/ or /etc/profile.d/ or home directory of user.
Enter the command below:

ls -la

Open editor. Enter the command below:

vi .bash_profile

Add below line to .bash_profile file. JAVA_HOME value, get from Step 3.1.

export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java
export PATH=$PATH:$JAVA_HOME/bin

3. To apply configuration.

Enter the command below:

source ~/.bash_profile

4. Confirm Environment variable value.
Enter the command below:

echo $JAVA_HOME

Step 3: Verify the installation.

Enter the command below:

java -version

III. Conclusion.

In this tutorial, we was install JDK on Linux – CentOS 7 server. If you hit a problem or have feedback, leave a comment below.


Install JDK on Linux – CentOS 7 is complete. Wish you success and luck.
Thanks and best regards!
— Pring —

Related Articles

Leave a Comment