Automating Oracle JDK Updates Using JMS' Java Download

Keeping Java up-to-date requires using the latest Java feature release or Java patch release available for build tools, CI/CD pipelines, Docker images, containers, or applications. Automatic provisioning of Java entails picking the right release based on policies, rules, and specifications, without human intervention. For instance, build tools such as Maven and Gradle are configured to automatically detect Java runtimes in the local filesystem, but do not have the capability to automatically update Oracle JDK if it is not up to date. Another example is Dockerfiles, text files that have instructions to assemble a container image. Often, the Dockerfile includes a URL for a specific version, and to stay updated with the latest release, the file needs to be manually updated after each new release.

Downloads of updates to the latest Oracle JDK versions, offered under the No Fee Terms and Conditions (NFTC), can be automated using script-friendly download URLs from the Java downloads page, for as long as they are offered under those terms, but download of updates of earlier versions like Java 8 and 11 (and starting in October of 2024, Java 17), offered under Oracle Technology Network (OTN) license terms, can’t be automated from as easily since accessing those releases requires users to login with an Oracle account and to accept the license terms each time.

To allow for automated downloads of updates to older Oracle JDK versions, in November 2023, Oracle introduced the Java Download Service through Java Management Service (JMS) on Oracle Cloud Infrastructure (OCI). This capability is tailored to meet the needs of Java developers, administrators, and software providers. JMS’s Java Download provides more options by allowing script-friendly downloads for all supported JDK versions, including versions under the Oracle Technology Network (OTN) License which require license acceptance. JMS, with its script-friendly download feature, facilitates the seamless use of up-to-date Java releases in your automated build and deployment system using token-based authentication.

Tokens for Authentication & License Acceptance

Authentication tokens streamline user access to cloud services by eliminating the need to log in for each interaction. In the context of JMS Java Download, tokens play a pivotal role in facilitating automatic downloads for all Java versions in scripts and Dockerfiles. These tokens, created by a JMS administrator after accepting the applicable license terms, allow the use of script-friendly download commands. Download requests are subject to validation of the associated token by JMS Java Download servers.

Java Download allows administrators to generates unique tokens for each Java version. The validity of each token is customizable and can be for multiple years. The generated tokens can be distributed to all users within the organization, even those without OCI accounts, to be used in applications and scripts that will download up-to-date versions of the JDK.

Token generation and Download flow is depicted in the functional workflow below.

Oracle JDK download functional workflow

JMS Java Download provides a token management interface for JMS administrators to create, revoke, and update the tokens in the JMS console, accessible using an OCI account. If you are new to OCI, you can create an Oracle Cloud Free Tier account, which allows permanent access to JMS and includes a time-limited trial to all OCI services. The trial period includes $300 of cloud credits that are valid for up to 30 days. You can spend these credits on any eligible Oracle Cloud Infrastructure service. There is no cost for JMS (although you might incur some cost for data storage if you go above the always-free storage limit) so you can continue using your OCI account for managing and using JMS download tokens even after the end of the trial period.

Oracle Cloud Infrastructure is available from 48 public cloud regions in 24 countries. JMS Java Download service allows you to create tokens and download Java from any region. This allows developers and system administrators to choose the location closest to the systems downloading the JDK and to comply with data locality requirements.

Tokens are by default valid for as long as updates to that Oracle JDK version are offered under the current terms. This means that newer versions under No-Fee-Terms-and-Conditions will be offered for up to 3 years for LTS releases and until the end of support life (EOSL date) for releases under the Java SE OTN License terms. Tokens for NTFC releases that reach end-of-permissive-licensing can only be extended, to continue accessing newer updates under the new license terms, if the administrator first accepts the new terms.

Download Reports

Java Download has a report section that allows reviewing all the JDK downloads that used each token. The download reports offer breakdown of the number of downloads according to various criteria such as Java version, releases under a specific version, operating system, architecture etc. The console provides drill-down capabilities to detailed download information all the way to the individual downloaded JDK binary. Reports can also be downloaded in CSV format.

Practical Applications of Scriptable Downloads

The scriptable download capability provided by JMS’s Java Download unlocks new possibilities for tools, libraries, plugins, CI/CD pipelines, and browser extensions involved in the discovery and download of Java. This feature enables the automatic provisioning of the latest Oracle JDK releases, solving a range of use cases, a few of which are outlined below.

Automatic Download / Auto-Provisioning of Oracle JDK in Maven/Gradle

Auto-detection of Java is supported by both Maven and Gradle based on toolchain/build config file. Auto-detection requires a JDK to be downloaded manually and stored locally. Neither Maven nor Gradle supports automatic download or auto provisioning of Oracle JDK. However, both Maven and Gradle have external plugins that support auto-download/auto-provisioning for Oracle’s OpenJDK builds. On the same lines, scriptable download in JMS can be used to support automatic downloads of Oracle JDK.

Always current Dockerfiles

Dockerfiles have instructions that create container images. Java Download provides starter/sample Dockerfiles that build container images using the latest Oracle JDK update available at the time when the image is created. These images use Oracle Linux 8 as the base layers which (as they are sample files) can be modified to use any version required.

JMS offers two types of Dockerfiles:

  1. Dockerfile using “Current Releases”: This is recommended for most users as it will create images with up-to-date versions of Java. These files will retrieve the latest release of the selected Java version. E.g. a user that wants JDK 21 will get 21.0.2 until April of 2024, then 21.0.3 until July of 2024, then 21.0.4 and so on…

  2. Dockerfile from Archive Releases: These Dockerfiles retrieve a specific update version. This is useful when a specific JDK release is required. A user can specify 21.0.2 and will get that exact version even after 21.0.3 is released. These Dockerfiles are recommended only when an out-of-date Java version is required, for example to debug issues on older versions.

Automate JDK Download in CI/CD Pipeline

Script-friendly download commands can be effectively used in CI/CD tools to ensure the pipeline always downloads the latest JDK version with the most up-to-date security fixes without manual intervention. For example, a typical Dockerfile for CI build functions can include a command like below to install a Java version:

RUN rpm -ivh

Users need to track the latest JDK releases and manually update versions numbers. This process can be automated using JMS’s scriptable download, eliminating the need for manual tracking of Oracle JDK releases and updating of Dockerfiles, by using the following command instead:

\ curl -H "token:<your_token_here>" -L --output /tmp/jdk.rpm "$JAVA_PKG";
\ rpm -ivh /tmp/jdk.rpm;

Additional resources