Skip to main content

Use javm in CI

In CI, install a pinned javm release, install the JDK that the project asks for, and run every Java command through javm exec. No shell integration is needed.

GitHub Actions​

On Linux and macOS runners:

steps:
- uses: actions/checkout@v4
- name: Install javm
run: |
curl -fsSL https://javm.dev/install.sh | bash -s v0.17.0
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- run: javm install # JDK from .java-version
- run: javm exec ./gradlew build

On Windows runners (PowerShell):

steps:
- uses: actions/checkout@v4
- name: Install javm
run: |
iex "& { $(irm https://javm.dev/install.ps1) } v0.17.0"
"$env:LOCALAPPDATA\Programs\javm" >> $env:GITHUB_PATH
- run: javm install
- run: javm exec .\gradlew.bat build

Writing the install directory to GITHUB_PATH makes javm available in the following steps.

Other CI systems​

The same three steps apply anywhere:

  1. Install a pinned javm release and put its directory on PATH ($HOME/.local/bin on Linux and macOS, %LOCALAPPDATA%\Programs\javm on Windows).
  2. Run javm install in the project directory, or javm install <selector>.
  3. Run builds and tests with javm exec <command>.

Tips​

  • Pin the javm version (v0.17.0 above) so pipeline behavior only changes when you update it. javm is before 1.0, and commands may change between minor versions.
  • Pin the JDK in .java-version with an exact version (for example 21.0.5) when builds must be reproducible; a feature version such as 21 resolves to the newest available build.
  • Use exit codes to tell failures apart: 3 means the JDK was not found, 4 a download or remote service failure.
  • To use another distribution without editing .java-version, run javm config set java.default_distribution <distribution> before javm install.