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:[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): 

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

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:

macOS JDK 19: 

⚠️ 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!