Download a JDK from https://jdk.java.net, including Early-Access builds.
Use the downloaded JDK file and its version as inputs for actions/setup-java@v2.
setup-java@v1
is supported, too.
Required The feature number or the project name of the JDK to be downloaded.
Defaults to 16
for the time being -- will default to the highest GA feature number available, soon.
Possible values include:
17
16
Loom
Panama
Valhalla
Archived versions are supported, too, in order 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.
The local path to the downloaded JDK archive.
You may also access the path via ${{ env.JDK_FILE }}
.
The version of the downloaded JDK archive.
You may also access the version via ${{ env.JDK_VERSION }}
.
Most examples below make use of environment variables to share file locations and JDK version information.
If you prefer using explicit identifiers, replace them with the correct id
tokens.
The first example shows both ways.
No with:
-argument is passed to sormuras/download-jdk
.
The "latest-and-greatest" GA version of the JDK is selected by default.
This example use of environment variables to share file locations and JDK version information.
- uses: sormuras/download-jdk@v1
- uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: jdkfile
jdkFile: ${{ env.JDK_FILE }}
- run: java -version
The same can be achieved using explicit identifiers and output names.
- uses: sormuras/download-jdk@v1
id: download-jdk
- uses: actions/setup-java@v2
with:
java-version: ${{ steps.download-jdk.outputs.version }}
distribution: jdkfile
jdkFile: ${{ steps.download-jdk.outputs.file }}
- run: java -version
Pass in a valid release number from 17 (or the current feature release number) down to 9 to feature: RELEASE
.
- uses: sormuras/download-jdk@v1
with:
feature: 17
- uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: jdkfile
jdkFile: ${{ env.JDK_FILE }}
- run: java -version
Most of the releases, those that are older than 6 months, are archived.
WARNING These 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.
Pass in a valid release number from 17 (or the current feature release number) down to 9 to feature: RELEASE
.
- uses: sormuras/download-jdk@v1
with:
feature: Loom
- uses: actions/setup-java@v2
with:
java-version: ${{ env.JDK_VERSION }}
distribution: jdkfile
jdkFile: ${{ env.JDK_FILE }}
- run: java -version
Most examples shown above also work with v1
of actions/setup-java
:
omit the distribution: jdkfile
line.