How to Install Java on CentOS

Install Java on CentOS

Java is required for running some games on your Linux VPS including Minecraft. The object-oriented programming language powers many websites and applications on computers and mobile devices. Below we cover how to:

You need root access to your linux server on your VPS or Dedicated server to continue.

Install Java on CentOS

The installation process consists of installing OpenJDK, the open source Java implementation which includes Font Renderer, or proprietary Oracle JRE/JDK with Flight Recorder which builds on top of OpenJDK.

We recommend OpenJDK for the latest features. You may prefer Oracle JRE/JDK for stability.

Install OpenJDK

  1. Log into SSH as root
  2. Search for the latest Java version:
    yum search openjdk
  3. Install the latest version. As of January 25, 2021:
    yum install java-11-openjdk
  4. You may see the following command afterward: There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don't work you'll have to try removing/installing packages by hand (maybe package-cleanup can help).
    If so, run the following to finish incomplete commands:
    yum-complete-transaction --cleanup-only

    yum history redo last

Install Oracle JRE/JDK

  1. Visit https://www.oracle.com/java/technologies/javase-downloads.html
  2. Select JDK Download for the latest Java SE version (version 15 as of January 25, 2021)
  3. Download the Linux RPM package
  4. (Optional) Verify the SHA256 checksum of the downloaded file on your Windows, Mac, or Linux machine against the checksum on the downloads page
  5. Upload the RPM file package to your server via cPanel, FTP, or SSH
  6. Install the RPM package as user root:
    yum install /path-to-file/jdk-[version].rpm

Using Ansible? Consider using a Java Ansible role within your playbooks. Learn more about the possibilities with IT automation in our Ansible Education Channel.

Check Java Download Version

Check your Java status to ensure it’s installed correctly:

java -version

You should see similar results to below:

Java version 15.0.2 information

Uninstall Java

If you no longer need Java, uninstall the CentOS repo in SSH.

Learn more about managing your linux server with our Managed VPS Hosting Product Guide.

J
Jacqueem Content Writer I

Technical writer focused on cybersecurity and musicianship.

More Articles by Jacqueem

Was this article helpful? Let us know!