How to Install Java Development Kit (JDK) on CentOS

Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), a compiler (javac), a documentation generator (javadoc), and other development tools. Installing the JDK on your CentOS system allows you to develop, compile, and run Java applications.

In this step-by-step guide, we will show you how to install the Java Development Kit (JDK) on a CentOS system. We will cover the installation process for both OpenJDK, an open-source implementation of the Java Platform, and Oracle JDK, the official Java development kit from Oracle.

Step 1: Update Your System

Before installing the JDK, it’s a good idea to update your system packages to ensure you’re working with the latest software. Run the following command to update your CentOS system:

sudo yum update -y

Step 2: Install OpenJDK or Oracle JDK

You can choose to install either OpenJDK or Oracle JDK, depending on your requirements.

See also  How to Upgrade Zimbra Collaboration Suite 8.0.1 to 8.0.2 on CentOS 6.3 x86_64

Install OpenJDK

To install OpenJDK, run the following command:

sudo yum install -y java-11-openjdk-devel

Replace “11” with the desired version of OpenJDK, if needed.

Install Oracle JDK

To install Oracle JDK, follow these steps:

Download the latest Oracle JDK from the official Oracle website:

Upload the downloaded tarball (e.g., jdk-11.x.x_linux-x64_bin.tar.gz) to your CentOS system.

Extract the tarball and move the extracted directory to /opt:

sudo tar -xf jdk-11.x.x_linux-x64_bin.tar.gz
sudo mv jdk-11.x.x /opt/jdk11

Replace “11.x.x” with the actual version numbers.

Set the necessary environment variables:

echo 'export JAVA_HOME=/opt/jdk11' | sudo tee /etc/profile.d/
echo 'export PATH=$PATH:$JAVA_HOME/bin' | sudo tee -a /etc/profile.d/
source /etc/profile.d/

Step 3: Verify the Installation

To verify that the JDK has been installed correctly, run the following command:

java -version

This command will display the installed JDK version and its details.

See also  How to Install Hadoop in Linux

Commands Mentioned:

  • yum update – Update installed packages on CentOS
  • yum install – Install specified packages and their dependencies on CentOS
  • tar – Extract or create compressed files
  • mv – Move or rename files and directories
  • echo – Print a string to the terminal or a file
  • tee – Redirect output to multiple destinations
  • source – Execute the contents of a file in the current shell
  • java – Launch a Java application or display Java information


In this guide, we have demonstrated how to install the Java Development Kit (JDK) on a CentOS system, covering both OpenJDK and Oracle JDK options. By following the steps outlined in this guide, you have successfully set up your CentOS system for Java application development.

It’s important to keep your JDK installation up to date, as new versions often include security patches, bug fixes, and performance improvements. Regularly check the official OpenJDK or Oracle websites for updates, and apply them as needed to maintain a secure and efficient development environment.

See also  How to Install Bind Chroot DNS Server on CentOS 6.2

With the JDK installed, you can now develop, compile, and run Java applications on your CentOS system. To further improve your Java development experience, consider installing an integrated development environment (IDE) like Eclipse or IntelliJ IDEA, which offers advanced code editing, debugging, and refactoring features.

We hope this guide has helped you successfully install the Java Development Kit (JDK) on your CentOS system. If you have any questions, comments, or suggestions for improvement, please feel free to share your thoughts in the comments section below. Your feedback is invaluable to us, and it helps us create better and more informative content for our users.


Leave a Reply

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