How‑to Guide
Common tasks and recipes with javm.
Switch versions
- Use a specific version or range:
javm use temurin@21javm use zulu@~1.8.144(equivalent to>=1.8.144 <1.9.0)
- Without arguments, javm reads
.java-versionin the current directory:javm use
- Check the current version:
javm current
Set default version for new shells
- Set the default:
javm default temurin@21
- Effect:
- Creates
default-versionin javm config dir. javm init <shell>will includejavm use <version>so new shells use it automatically.
- Creates
Discover local JDKs
- Refresh discovery cache:
javm discover refresh(forces refresh)
- List discovered JDKs:
javm discover list
- Show detailed information (source, version, vendor, implementation, arch, path):
javm discover list --detailsorjavm discover list -d
Link / unlink a system JDK
- Link an existing (unmanaged) JDK for use via javm:
javm link system@1.8.72 /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk- Name must begin with
system@and be a valid semver selector.
- Show a link target:
javm link system@1.8.72
- Remove the link:
javm unlink system@1.8.72
- Use it:
javm use system@~1.8
Aliases
- Create or update an alias:
javm alias default temurin@21
- Resolve an alias value:
javm alias default
- Delete an alias:
javm unalias default
- Notes:
- Aliases are stored as
*.aliasfiles in the javm config dir. - Alias updates automatically relink the
jdk\aliassymlink to the best match.
- Aliases are stored as
List versions (installed vs remote)
- Installed:
javm ls- Filter by range:
javm ls "~21" - Show latest majors/minors/patches:
javm ls --latest=minor
- Remote (available to install):
javm ls-remote(defaults:--oscurrent,--archcurrent,--distribution temurin)- All distributions:
javm ls-remote --distribution=all - Filter by range:
javm ls-remote zulu@">=1.8 <1.9" - Show only latest:
javm ls-remote --latest=major|minor|patch
Which JDK path
- Resolve path to an installed JDK matching a selector:
javm which temurin@21
- Use
.java-versionif no argument is provided:javm which
- macOS: use
--hometo append/Contents/Homeso the result is suitable forJAVA_HOME:javm which temurin@21 --home
Troubleshooting
- See all commands:
javm --help - Increase logs:
javm --debug(verbose) orjavm --quiet(warnings only) - Ensure your shell profile runs
javm init <shell>on startup.