Java is a high-level 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). In this tutorial we will see how to install latest Java 17 on Linux servers.
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. Non-LTS releases are supported for 6 months only.
Now Java 17, latest long-term support (LTS) version released and now available for production use. You can use Java 11 also for production which is also LTS version.
Please check here to install OpenJDK Java 11 on Linux server
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 under the open source license.
For more information visit : Java/OpenJDK website.
Java versions, Release Dates and EOL:
Version | Release Date | End of life |
19 | 20 Sep 2022 | 21 Mar 2023 |
18 | 22 Mar 2022 | 20 Sep 2022 |
17 (LTS) | 14 Sep 2021 | 30 Sep 2029 |
11(LTS) | 25 Sep 2018 | 30 Sep 2026 |
8 (LTS) | 18 Mar 2014 | 31 Dec 2030 |
Always try to upgrade java version whenever the new version updates are available, to keep application up to date. Updated version can improve security, add functionality, and improve the speed of application.
If you are interested to read Difference between JDK, JRE, and JVM click here
Steps to install Java 17 on Linux server
This tutorial help you to install latest Java 17 on Linux servers like CentOS, RHEL, Oracle Linux, Rocky Linux, AlmaLinux and Ubuntu. We’ll show you how to install OpenJDK 17 as well as Oracle Java 17.
WARNING: 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 17 on Linux server.
1. OpenJDK Java 17 (Recommended)
# cd /opt && wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz
OR
2. Adoptium Java 17
# cd /opt && wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.6%2B10/OpenJDK17U-jdk_x64_linux_hotspot_17.0.6_10.tar.gz
OR
3. Oracle Java 17
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.
# cd /opt && wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
Now next step is extract downloaded Java tar file and rename it:
# tar -xvzf *jdk*17*.tar.gz && rm -rf *jdk*17*.tar.gz && mv *jdk-17* java
Then set installed Java 17 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 17 from Linux server
To completely remove Java 17 from a system, you must remove the Java applications, the configuration files, and any directories containing data.
WARNING: This process will completely remove Java 17 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 17 on Linux system like CentOS, RHEL, Rocky Linux, AlmaLinux, Ubuntu and Debian. We hope this 2 minutes stuff helped you and thank you for visiting our website.
Cheers!!!