Easily switch between different JDK and Maven versions on a per-workspace basis.
- Switch Workspace JDK: Change the JDK version for your current workspace.
- Switch Workspace Maven: Change the Maven version for your current workspace.
- Auto-discovery: Automatically discovers installed JDKs and Mavens on your system.
- Terminal Integration: Configures integrated terminals to use the selected JDK and Maven versions (
JAVA_HOME,M2_HOME, andPATH). - Automatic Configuration: Updates settings for popular Java-related extensions.
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+Pon Mac). - Type
Java Switcherto see the available commands. - Select Java Switcher: Switch Workspace JDK to choose a JDK version.
- Select Java Switcher: Switch Workspace Maven to choose a Maven version.
- The extension will update your workspace
settings.jsonfile with the selected paths.
This extension is designed to be zero-config. It works by dynamically updating your VS Code settings when you switch versions.
When you switch versions, this extension will set the following configuration in your workspace settings.json:
javaSwitcher.java.home: Stores the path of the selected JDK.javaSwitcher.maven.home: Stores the path of the selected Maven installation.
Based on your selection, the extension will automatically update the following settings for other popular extensions to ensure a consistent environment:
For JDK selection:
java.jdt.ls.java.home(for Red Hat's Java extension)spring-boot.ls.java.home(for VMware's Spring Boot extension)java.import.gradle.java.home(for Red Hat's Java extension)zopeneditor.JAVA_HOME(for IBM's Z Open Editor)plantuml.java(for Jebbs' PlantUML extension)rsp-ui.rsp.java.home(for Red Hat's RSP UI extension)salesforcedx-vscode-apex.java.home(for Salesforce's Apex extension)metals.javaHome(for Scalameta's Metals extension)java.configuration.runtimes(for Red Hat's Java extension)maven.terminal.customEnv(for Red Hat's Java extension)
For Maven selection:
maven.executable.path(for Red Hat's Java extension)
You do not need to manually configure these settings. The extension handles them for you.
This project is licensed under the MIT License - see the LICENSE file for details.