Manage Java versions on Windows
javm runs natively on Windows: it is a single javm.exe that works in PowerShell and Command Prompt, without WSL or
Git Bash. It installs JDKs for your user account, so it needs no administrator rights, and it never changes the
system-wide JAVA_HOME or the registry.
Install javm
In PowerShell:
irm https://javm.dev/install.ps1 | iex
The installer places javm.exe in %LOCALAPPDATA%\Programs\javm, adds that directory to your user PATH, and updates
the current PowerShell session. Terminals that were already open need a restart to see it. Check it with:
javm --version
See Install javm for pinned versions, provenance verification, upgrades, and uninstalling.
Install JDKs
javm install temurin@21
javm install temurin@25
javm ls
JDKs are stored per user in %LOCALAPPDATA%\javm\jdk. javm also lists JDKs it finds on the machine, such as the ones
IntelliJ IDEA or Gradle downloaded, so you can use them without reinstalling. See
Use JDKs you already have.
javm also creates shortcut links there, such as temurin@21.0. Windows allows them only with
Developer Mode or an
elevated prompt. Without them javm prints a warning and keeps working, except for javm link and javm alias, which
need the link.
Run Maven with the project's JDK
Put the version in .java-version at the project root, then run the build through javm exec:
"21" | Out-File -Encoding ascii .java-version
javm install
javm exec mvn verify
Keep -Encoding ascii: Windows PowerShell 5.1 otherwise writes UTF-16, which javm and other tools cannot read.
javm exec sets JAVA_HOME and PATH only for that command, so it works in any terminal and in CI without shell
setup. Batch wrappers such as mvn.cmd and gradlew.bat run through cmd.exe, as Windows requires. See
Run commands with a JDK.
Switch JAVA_HOME in PowerShell
To change java and JAVA_HOME in the PowerShell session itself, load the shell integration once by adding this
line to your profile (echo $PROFILE prints its path):
iex "$(javm init pwsh)"
Then, in a new session:
javm use 21
java --version
$env:JAVA_HOME
javm deactivate # restores the previous JAVA_HOME and PATH
Switch JAVA_HOME in Command Prompt
Command Prompt uses a small javm.cmd wrapper, generated once into its own directory:
mkdir "%LOCALAPPDATA%\javm\cmd" 2>NUL
javm init cmd > "%LOCALAPPDATA%\javm\cmd\javm.cmd"
set "PATH=%LOCALAPPDATA%\javm\cmd;%PATH%"
To make it permanent, add %LOCALAPPDATA%\javm\cmd to your user Path in the Windows environment-variable settings,
before %LOCALAPPDATA%\Programs\javm, and open a new Command Prompt. Then:
javm use 21
echo %JAVA_HOME%
javm deactivate
In batch files, write call javm use 21 so the script continues after the command. See
Shell setup for the details.
Choose the JDK for new terminals
javm default temurin@21
New PowerShell sessions that load the shell integration start with that JDK. In Command Prompt, the javm.cmd
wrapper applies it the first time you run javm in a window. javm does not set a machine-wide JAVA_HOME; for an
IDE, point its JDK setting at the path printed by javm which 21.
Troubleshooting
javmis not recognized in a terminal opened before the installation: open a new terminal so it reads the updated userPATH.javm usereports that shell integration is not active: the profile line or thejavm.cmdwrapper is not loaded. In Command Prompt, check that the wrapper directory comes before%LOCALAPPDATA%\Programs\javminPATH.javastill points to another JDK afterjavm use: runGet-Command javain PowerShell orwhere javain Command Prompt to see which one wins.- A warning that a link could not be created: enable Developer Mode, or ignore it; see Install JDKs.
More cases are in Troubleshooting.