Fast JDK version switching for Windows via directory symlinks
This project was born out of my personal frustration with having to manually switch between different JDK versions on Windows. The traditional approach of constantly updating JAVA_HOME and PATH environment variables, followed by restarting terminals, command prompts, and IDEs, was way too time-consuming and error-prone. I wanted a solution that would allow me to switch JDK versions instantly without any restarts or manual environment variable manipulation.
JDK Switcher solves this problem by using a single directory symlink (C:\jdk or similar) that can be quickly redirected to any installed JDK version. Since the environment variables are configured once and point to this symlink, switching JDK versions becomes a simple matter of updating the symlink target—no restarts required.
- Instant JDK switching - Change between JDK versions without restarting terminals, command prompts, or IDEs
- One-time setup - Configure
JAVA_HOMEandPATHonce, never touch them again - Version symlinks - Automatically creates major version shortcuts (e.g.,
11,17,21) that point to the latest installed version of each JDK - Latest version quick-switch - Quickly switch to the newest major JDK version with the
latestkeyword - JDK vendor-agnostic - Works with any JDK distribution (Oracle, Temurin, Zulu, Microsoft, etc.)
- Simple commands - Three easy-to-use scripts for initialization, switching, and updating
- IntelliJ IDEA compatible - Default directory structure matches IntelliJ IDEA's JDK download location and naming convention
- Windows 10/11 (or any other Windows version with symlink support)
- Groovy installed and available in PATH (Download Groovy)
- Administrator privileges (required for initial setup and creating symlinks by default)
- Alternative: Enable Windows Developer Mode or grant
SeCreateSymbolicLinkPrivilegeto your user account to create symlinks without elevation
- Alternative: Enable Windows Developer Mode or grant
- One or more JDK installations
git clone https://github.com/vdenisov/jdk-switcher.git
cd jdk-switcherOr download and extract the ZIP file to a local directory.
Add the directory containing the JDK Switcher scripts to your system PATH so you can run them from anywhere.
Install your JDK distributions into %USERPROFILE%\.jdks\ using the naming convention <vendor>-<version>.
Examples:
temurin-17.0.12temurin-21.0.5zulu-11.0.25oracle-23.0.1
Note 1: This default directory (%USERPROFILE%\.jdks) and naming convention is compatible with IntelliJ IDEA's automatic JDK downloads, making it easy to use JDKs managed by IntelliJ with this tool.
Note 2: You can use symlinks to link to other locations, not just %USERPROFILE%\.jdks.
Edit config.properties to customize the installation paths if needed:
# Base directory where JDK installations are stored (relative to user home)
jdks.base.dir=.jdks
# Path where the active JDK symlink will be created
jdks.symlink.path=C:\\jdkOpen an elevated command prompt (Run as Administrator) and execute:
jdk-initThis script will:
- Verify your
.jdksdirectory exists - Add
C:\jdk\binto your systemPATH - Set
JAVA_HOMEtoC:\jdk - Create major version symlinks (e.g.,
11,17,21) - Switch to the latest JDK version
The config.properties file contains two settings:
| Property | Description | Default Value |
|---|---|---|
jdks.base.dir |
Directory where JDKs are installed (relative to %USERPROFILE%) |
.jdks |
jdks.symlink.path |
Absolute path where the active JDK symlink will be created | C:\jdk |
Example:
jdks.base.dir=.jdks
jdks.symlink.path=C:\\jdkjdks 17Switches to JDK 17 (uses the symlink %USERPROFILE%\.jdks\17, which points to the latest installed JDK 17).
jdks latestAutomatically detects and switches to the highest major version available.
After installing a new JDK, run:
jdk-updateThis scans your .jdks directory and updates the major version symlinks to point to the latest patch version for each major release.
Example: If you have temurin-17.0.10 and temurin-17.0.12, the 17 symlink will point to temurin-17.0.12.
jdk-update 17Updates only the JDK 17 symlink to point to the latest installed JDK 17 version.
You can manually set a version symlink to point to a specific JDK installation using either a relative path (relative to .jdks) or an absolute path.
Using a relative path:
jdk-update 17 temurin-17.0.10Using an absolute path (e.g., standard Temurin installation):
jdk-update 17 "C:\Program Files\Eclipse Adoptium\jdk-17.0.12.7-hotspot"This flexibility allows you to manage JDKs installed in different locations, not just those in your .jdks directory.
JDK Switcher uses a two-tier symlink architecture to provide JDK switching without the need for configuration files or persistent version mappings.
Located in %USERPROFILE%\.jdks\, these are numeric directory symlinks that point to specific JDK installations:
C:\Users\YourName\.jdks\
├── 11 → zulu-11.0.25
├── 17 → temurin-17.0.12
├── 21 → temurin-21.0.5
├── zulu-11.0.25\
├── temurin-17.0.12\
└── temurin-21.0.5\
The jdk-update script manages these symlinks, automatically pointing each major version to the latest installed patch version.
Why major version symlinks? This tier provides two key benefits:
- No configuration files needed - The symlinks themselves store the version mappings directly in the filesystem
- Third-party tool integration - Other tools (IDEs, build scripts, Docker files) can reference
%USERPROFILE%\.jdks\17directly, and you can transparently upgrade minor JDK versions by simply runningjdk-updatewithout reconfiguring those tools
A single directory symlink at C:\jdk points to one of the major version symlinks:
C:\jdk → C:\Users\YourName\.jdks\17
The jdks script updates this symlink to switch between JDK versions. This provides the global "active" JDK used by your system.
The system environment variables are configured once during initialization:
JAVA_HOME:C:\jdkPATH:C:\jdk\bin(prepended as the very first entry, feel free to reorder if needed)
Since these variables point to the symlink, no environment variable changes are needed when switching versions. The symlink redirection happens instantly, and the new JDK version is immediately available in all open terminals and applications.
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit issues or pull requests.
This tool was inspired by:
- Unix/Linux tools like
update-alternativesfor system-wide version management - JDK management tools like SDKMAN! for their user-friendly approach to JDK switching
- The
jvmstool, from which I borrowed the symlink-based approach for JDK version management on Windows