Java is a high-level, object-oriented programming language that relies on few dependencies as possible. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture so we call it WORA (Write Once, Run Anywhere). If you’re looking for a simple program or a complex system, Java is a great choice. In this article we’ll see how to install java 11 on Linux server.

The Java programming language  developed by the Sun Microsystems under OpenJDK Project, now owned by Oracle, has been on a 6-month rapid-release cycle since the release of Java 10, and starting with Java 11, has new LTS releases every three years. Java 8 is the last release on the old cycle methodology and still has 8 years security support. Non-LTS releases are supported for 6 months only.

Java comes in 2 type: Open Source OpenJDK under the GNU GPL which is free of cost, and Oracle JDK a proprietary license that must be purchased. Other projects such as Adoptium or Linux distributions may provide builds external to Oracle and are governed under the open source license.

For more information visit : Java/OpenJDK website.

Java versions, Release Dates and EOL:

VersionRelease DateEnd of life
17 (LTS)14 Sep 202130 Sep 2029
11(LTS)25 Sep 201830 Sep 2026
8 (LTS)18 Mar 201431 Dec 2030
JAVA EOL

If you are not sure which Java version can prefer to install on server, Our recommendation is to install Java 11, which is the LTS version of Java.

If you want to install Latest LTS Java 17 then check here

JDK vs JRE vs JVM

When I was in college, I also confused with these words but now I will explain it in simple word :

  • JDK is for development purpose whereas JRE is for running the java programs.
  • JDK and JRE both have JVM so that we can run our java program on both.
  • JVM is the heart of java programming language and provides platform independence.
jdk vr jre vr jvm
JDK vr JRE vr JVM

Steps to install Java 11 on Linux server

This tutorial help you to install Java 11 on Linux servers like CentOS, RHEL, Oracle Linux, Rocky Linux, AlmaLinux and Ubuntu. We’ll show you how to install OpenJDK 11 as well as Oracle Java 11.

WARNING: Older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production. For production use Oracle recommends downloading the latest JDK and JRE versions and allowing auto-update.

Prerequisites:

  • sudo privileges.
  • Stable internet connection.

Check server OS version:

# egrep '^(VERSION|NAME)=' /etc/os-release

Install the prerequisites:

For RHEL, CentOS and Oracle Linux 7
# yum install wget -y

For RHEL, CentOS and Oracle Linux 8 and 9
# dnf install wget -y

For Ubuntu and Debian server
# apt install wget -y

We have 3 options to download Java 11 on Linux server.

1. OpenJDK Java 11 (Recommended)

# cd /opt && wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz

OR

2. Adoptium Java 11

# cd /opt && wget https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.18%2B10/OpenJDK11U-jdk_x64_linux_hotspot_11.0.18_10.tar.gz

OR

3. Oracle Java 11

Before installing Oracle Java, make sure you read the Oracle JDK License . The license permits only non-commercial use of the software, such as personal use and development use. To download Oracle Java, you need to register on the Oracle site so register and download .tar.gz from here Linux x64 Compressed Archive. Now upload downloaded file to Linux server and copy it to /opt directory.

Now next step is extract downloaded Java tar file and rename it:

# tar -xvzf *jdk*11*.tar.gz && rm -rf *jdk*11*.tar.gz && mv *jdk-11* java

Then set installed Java 11 version to default Java version:

# update-alternatives --install /usr/bin/java java /opt/java/bin/java 1

Verify installed version of Java:

# java -version

Uninstall Java 11 from Linux server

To completely remove Java 11 from a system, you must remove the Java applications, the configuration files, and any directories containing data.

WARNING: This process will completely remove Java 11 and its configuration. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.

# rm -rf /opt/java && update-alternatives --remove java /opt/java/bin/java

Conclusion

Congratulations! We’ve installed Java 11 on Linux system. We hope this 2 minutes stuff helped you and thank you for visiting our website.
Cheers!!!