Skip to main content

How‑to Guide

Common tasks and recipes with javm.

Switch versions

  • Use a specific version or range:
    • javm use temurin@21
    • javm use zulu@~1.8.144 (equivalent to >=1.8.144 <1.9.0)
  • Without arguments, javm reads .java-version in 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-version in javm config dir.
    • javm init <shell> will include javm use <version> so new shells use it automatically.

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 --details or javm discover list -d
  • 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 *.alias files in the javm config dir.
    • Alias updates automatically relink the jdk\alias symlink to the best match.

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: --os current, --arch current, --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-version if no argument is provided:
    • javm which
  • macOS: use --home to append /Contents/Home so the result is suitable for JAVA_HOME:
    • javm which temurin@21 --home

Troubleshooting

  • See all commands: javm --help
  • Increase logs: javm --debug (verbose) or javm --quiet (warnings only)
  • Ensure your shell profile runs javm init <shell> on startup.