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:
- Install a pinned javm release and put its directory on
PATH($HOME/.local/binon Linux and macOS,%LOCALAPPDATA%\Programs\javmon Windows). - Run
javm installin the project directory, orjavm install <selector>. - Run builds and tests with
javm exec <command>.
Tips
- Pin the javm version (
v0.17.0above) 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-versionwith an exact version (for example21.0.5) when builds must be reproducible; a feature version such as21resolves to the newest available build. - Use exit codes to tell failures apart:
3means the JDK was not found,4a download or remote service failure. - To use another distribution without editing
.java-version, runjavm config set java.default_distribution <distribution>beforejavm install.