Script Friendly JDK Download URLs - Sip of Java

As an industry, we have moved towards automated and more frequent deployments. This allows organizations to be more flexible in responding to user and business needs and addressing problems when issues arise. With deployment pipelines being heavily automated, the downloading and installing of the JDK must also be automatable. This article will look at how to use scriptable URLs to download and install Oracle-built JDKs.

Scriptable Download URLs

The scriptable download URLs were introduced roughly concurrent with the release of JDK 17 in September 2021. This is also when the new No-Fee Terms and Conditions (NFTC) License was introduced. Check the Additional Reading section for a link to the full (NFTC) license.

To be properly scriptable, the URLs must follow a consistent pattern that allows developers to know how to download the specific JDK they need intuitively. Let’s look at this pattern for downloading the latest version of the JDK:

https://download.oracle.com/java/[java-version]/latest/jdk-[java-version]_[os]-[cpu-architecture]_bin.[file-type]

That’s a bit hard to read, but if you wanted to download the latest Linux AArch64 JDK 19, it would look like this (both tar.gz and rpm file types shown):

https://download.oracle.com/java/19/latest/jdk-19_linux-aarch64_bin.tar.gz
https://download.oracle.com/java/19/latest/jdk-19_linux-aarch64_bin.rpm 

Alternatively, if you wanted the Windows MSI installer for JDK 17:

https://download.oracle.com/java/17/latest/jdk-17_windows-x64_bin.msi

Downloading Archived JDKs

In most cases, you will want to use the latest URL when automating JDK downloads; however, sometimes, downloading older versions of the JDK might be needed for testing purposes or compatibility reasons. To download an archived version of the JDK, replace latest in the URL with archive and use the full version name in the binary portion of the URL. Here are a couple of examples:

Linux JDK 17.0.5:

https://download.oracle.com/java/17/archive/jdk-17.0.5_linux-aarch64_bin.tar.gz

macOS JDK 19:

https://download.oracle.com/java/19/archive/jdk-19_macos-x64_bin.tar.gz 

⚠️ Warning: Older versions of the 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.

GitHub Action

If you are automating your builds with GitHub actions, a GitHub action is available for consuming the script-friendly URLs. It is located in the Oracle Actions GH Repo. Check the Additional Reading section for a link.

Additional Reading

JDK Script Friendly URLs

Java Downloads

Oracle’s setup-java GitHub Action

Oracle No-Fee Terms and Conditions License

Happy coding!