Manage multiple Java versions on macOS, Linux and Windows

Projects often need different JDKs, and setting JAVA_HOME by hand is easy to get wrong. AVM installs Temurin OpenJDK builds, pins one version per project and sets JAVA_HOME for you.

Install the Java plugin and a JDK

The Java plugin downloads Eclipse Temurin builds. List what is available, then install a major or exact version.

avm plugin add java
avm java versions
avm java install 21

Pin a JDK per project

avm java use writes the version to .avm.json for the current repository; add --global for a machine default. AVM also reads .java-version and .sdkmanrc, so existing projects work unchanged.

avm java use 21
avm java use 17 --global

JAVA_HOME without editing profiles

The plugin provides JAVA_HOME for the selected version when commands run through AVM, so you do not export it in your shell profile. Check the result with avm which java.

Build with another JDK once

Run a single command against a different JDK without touching your pins.

avm x java@17 -- ./gradlew build

Lock the JDK for CI

Java supports lockfiles. avm lock records exact releases and archive checksums for each platform, and avm install --frozen verifies them.

avm lock --platform linux_amd64,darwin_arm64,windows_amd64
avm install --frozen