How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (2024)

JDK 17, the open-source reference implementation of Java SE Platform version 17, was finalized through the Java Community Process under JSR 390. Officially available since 14 September 2021, it provides production-ready binaries under the GPL license from Oracle, with other vendors expected to release their binaries soon after. The development and features of JDK 17 were meticulously planned and tracked through the JEP Process, updated by JEP 2.0, and the release itself followed the guidelines of the JDK Release Process (JEP 3).

Key notes of the JDK 17 Release were:

  • JEP 306: Restore Always-Strict Floating-Point Semantics
    • Ensures that all floating-point operations strictly adhere to IEEE 754 standards.
  • JEP 356: Enhanced Pseudo-Random Number Generators
    • Provides new interfaces and implementations for random number generators, improving flexibility and performance.
  • JEP 382: New macOS Rendering Pipeline
    • Introduces a new rendering pipeline for macOS, using the Apple Metal framework to replace the deprecated OpenGL API.
  • JEP 391: macOS/AArch64 Port
    • Adds support for the macOS/AArch64 platform, enabling JDK to run on Apple’s new ARM-based Macs.
  • JEP 398: Deprecate the Applet API for Removal
    • Marks the Applet API for future removal, as it is outdated and largely unused in modern development.
  • JEP 403: Strongly Encapsulate JDK Internals
    • Enhances the security and integrity of the JDK by strongly encapsulating internal APIs.
  • JEP 406: Pattern Matching for switch (Preview)
    • Introduces pattern matching for the switch statement, allowing more concise and readable code.
  • JEP 407: Remove RMI Activation
    • Removes the RMI Activation mechanism, simplifying the RMI stack.
  • JEP 409: Sealed Classes
    • Allows the declaration of sealed classes and interfaces, which restrict which other classes or interfaces may extend or implement them.
  • JEP 410: Remove the Experimental AOT and JIT Compiler
    • Removes the experimental ahead-of-time (AOT) and just-in-time (JIT) compiler features, which were not widely adopted.
  • JEP 411: Deprecate the Security Manager for Removal
    • Marks the Security Manager for future removal, as it has been replaced by more modern security practices.
  • JEP 412: Foreign Function & Memory API (Incubator)
    • Introduces an incubating API for foreign function and memory access, which allows Java programs to interoperate with code and data outside the Java runtime.
  • JEP 414: Vector API (Second Incubator)
    • Provides an API for expressing vector computations that reliably compile to optimal vector instructions on supported CPU architectures.
  • JEP 415: Context-Specific Deserialization Filters
    • Enhances security by allowing the specification of context-specific deserialization filters.

JDK 17 is a long-term support (LTS) release, ensuring extended support and stability for enterprise use. The guide will now demonstrate two different methods to install OpenJDK 17 on Ubuntu, with the recommended method of using Ubuntu’s default repository.

Update Ubuntu before OpenJDK 17 Installation

Before installing OpenJDK, updating Ubuntu to ensure all system packages are current with the “apt update” command is essential. This helps to prevent any potential conflicts during the installation process. To update your Ubuntu system, run the following command in your terminal:

sudo apt updatesudo apt upgrade

Select OpenJDK Installation Method

Install OpenJDK 17 with Ubuntu Repository

The first and most recommended method for installing OpenJDK is through the default Ubuntu repository. You can search for available packages using the “grep” command. To do this, run the following command in your terminal:

apt-cache search openjdk | grep openjdk-17

Example output:

How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (1)

Depending on your version of Ubuntu, you may be able to install OpenJDK 17 JDE and JRE using the following command. This is only applicable if these packages are available in your distribution:

sudo apt install openjdk-17-jre
sudo apt install openjdk-17-jdk

Confirm the installation by running the following command.

java --version

Updates are handled with the standard apt update and upgrade commands. However, you can remove them separately or altogether if you no longer require JDK or JRE.

Example:

sudo apt remove openjdk-17-jre openjdk-17-jdk --purge

Note that this will remove any unrequited leftover dependencies and thoroughly wipe the installation and data from your system as much as possible.

Method 2: Install OpenJDK 17 Manual Method

The second method for installing OpenJDK 17 is downloading the .tar.gz archive package. While this option is often more up-to-date than the version in the Ubuntu repository, it requires more manual maintenance, as you’ll need to monitor new updates and repeat the installation process.

Visit the downloads page to obtain the latest build version link. Then, use the following wget command to download the package.

Here’s an example of downloading OpenJDK 17 version 17.0.2 for x64 (however, it is recommended to obtain a new link from the downloads page rather than copying this example):

wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz

Note: Remember, the above link is an example, so ensure you grab the latest build version.

Once the download process is complete, the archive will be extracted.

tar -xvf openjdk-17.*

Next, navigate to the directory.

cd <directory_name>

Run the following command to install the OpenJDK 17 files.

sudo mkdir -p /usr/local/openjdk-17sudo mv * /usr/local/openjdk-17

The next step is to set up the environment variables by adding the following lines to your .bashrc or .bash_profile file.

export JAVA_HOME=/usr/local/openjdk-17export PATH=$JAVA_HOME/bin:$PATH

Source the .bashrc or .bash_profile file to apply the changes.

source ~/.bashrc

To verify that the installation was successful, run the following command.

java --versionecho $JAVA_HOME

If installed correctly, you should see the following output:

How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (2)

As demonstrated, the version displayed is the latest OpenJDK 17 build.

Switching Alternative Java Versions

After installing Java, you may want to check for newer versions and switch to them if necessary. To do this, use the following command to list the available alternatives:

sudo update-alternatives --config java

Example output:

How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (3)

The previous output shows that Java 11 is listed with “1”. To switch to this version, type the following and press the enter key, and you should see a similar printout:

update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/java to provide /usr/bin/java (java) in manual mode

Once the switch is complete, you can verify the default version using the following command.

java --version

Example output:

How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (4)

To switch to any other installed versions, repeat the same process.

Conclusion

In conclusion, installing OpenJDK 17 on Ubuntu is straightforward and can be accomplished using several methods. Whether you use the default Ubuntu repository, download the .tar.gz archive package, or switch to a different version, the steps outlined in this article will help you successfully install and manage OpenJDK 17 on your Ubuntu system.

Useful Links

Here are some valuable links related to using OpenJDK 17 on an Ubuntu system:

  • OpenJDK 17 Project: Visit the OpenJDK 17 project page for detailed information about the JDK 17 release, features, and updates.
  • OpenJDK Wiki: Access the OpenJDK Wiki for comprehensive documentation, development guides, and community resources.
  • OpenJDK Downloads: Visit the OpenJDK download page to get the latest builds of JDK 17 and other versions.

These links provide additional information and resources to help you effectively use OpenJDK 17 on your Ubuntu system.

  • Author
  • Recent Posts

Follow me

Joshua James

Joshua James is a seasoned Linux system administrator with a wealth of experience in the field. As the main author and owner of linuxcapable.com, Joshua has authored numerous tutorials and guides that help users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, Fedora, Debian, RHEL, openSUSE, and Arch Linux. Joshua is renowned for his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and commitment to sharing knowledge have established him as a respected figure in the field.

Follow me

Latest posts by Joshua James (see all)

  • How to Configure Nginx for PHP-FPM on Fedora 40 or 39 - Monday, June 3, 2024
  • How to Install Firefox on Debian 12, 11 or 10 - Tuesday, January 30, 2024
  • Upgrade to Ubuntu 24.04 Noble Numbat Desktop or Server - Friday, January 12, 2024

Share This Post:

FacebookXRedditLinkedInTumblrEmailTelegramWhatsAppPinterestHacker NewsMastodonPocketVKFlipboardCopy

You may also like:

  1. How to Install OpenJDK 8 on Ubuntu 24.04, 22.04 or 20.04
  2. How to Install OpenJDK 21 on Ubuntu 22.04 or 20.04
  3. How to Install OpenJDK 11 on Ubuntu 22.04 or 20.04
  4. How to Install Apache Maven on Ubuntu 24.04, 22.04 or 20.04
  5. How to Install Wine on Ubuntu 24.04, 22.04 or 20.04
  6. How to Install Nvidia Drivers on Ubuntu 24.04, 22.04, or 20.04
  7. How to Install Firefox Beta and Nightly on Ubuntu 24.04, 22.04, or 20.04
  8. How to Install Python 3.8 on Ubuntu 22.04 or 20.04
  9. How to Install Telegram on Ubuntu 24.04, 22.04 or 20.04
  10. How to Install MySQL 8.0 on Ubuntu 24.04, 22.04, or 20.04
How to Install OpenJDK 17 on Ubuntu 24.04, 22.04 or 20.04 - LinuxCapable (2024)

References

Top Articles
Latest Posts
Article information

Author: Moshe Kshlerin

Last Updated:

Views: 5691

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Moshe Kshlerin

Birthday: 1994-01-25

Address: Suite 609 315 Lupita Unions, Ronnieburgh, MI 62697

Phone: +2424755286529

Job: District Education Designer

Hobby: Yoga, Gunsmithing, Singing, 3D printing, Nordic skating, Soapmaking, Juggling

Introduction: My name is Moshe Kshlerin, I am a gleaming, attractive, outstanding, pleasant, delightful, outstanding, famous person who loves writing and wants to share my knowledge and understanding with you.