Do not manually edit environment variables. Learn how to install Scoop and manage multiple Java Development Kit (JDK) versions (Java 17, 21). Learn how to configure Maven and Gradle. Learn how to integrate these tools with IntelliJ and VS Code.
In the past, Java installation on Windows required .exe installers, wizards, and manual changes to environment variables. Now, you can use Scoop. Scoop is a command-line installer for Windows. You can use Scoop to install, manage, and switch between multiple JDKs and build tools. You use a single command.
This guide tells you how to install Scoop, manage Java versions, and configure your development tools.
Step 1: Install Scoop
If you do not have Scoop, you can install it with PowerShell.
Open PowerShell. Make sure that the PowerShell window does not have Administrator privileges.
To let PowerShell run scripts, run this command:
Set-ExecutionPolicy-ExecutionPolicyRemoteSigned-ScopeCurrentUser
- To install Scoop, run this command:
irmget.scoop.sh|iex
- To make sure that the installation is complete, run this command:
scoop--version
Step 2: Add the Java bucket
By default, Scoop installs standard desktop applications. To install Java distributions, you must add the official Java bucket. A bucket is a managed repository of software manifests.
- Run this command in your terminal:
scoopbucketaddjava
Scoop can now access many JDKs. These JDKs include OpenJDK, Oracle JDK, Eclipse Temurin, Amazon Corretto, Zulu, and Microsoft JDK.
Step 3: Search for and install Java versions
You can search for available Java packages with the scoop search jdk command. Install two different versions to learn how to switch between them.
- To install the latest OpenJDK, run this command:
scoopinstallopenjdk
- To install specific Long-Term Support (LTS) versions, run these commands:
scoopinstallopenjdk17scoopinstalltemurin21-lts
Step 4: Switch between Java versions
Scoop uses symlinks (shortcuts). You do not manually change path variables. When you switch versions, Scoop updates the shortcut.
- To view your installed Java versions, run this command:
scooplist
Find your installed Java packages in the output list.
- To make a version active, use the
scoop resetcommand and the package name. For example:
scoopresetopenjdk17
- To make sure that the version is active, run this command:
java-version
If you must switch back to Java 21, run scoop reset temurin21-lts.
Step 5: Install Maven and Gradle
Scoop lets you install ecosystem tools easily. These tools are available in the default Scoop bucket.
- To install Maven, run this command:
scoopinstallmaven
- To install Gradle, run this command:
scoopinstallgradle
Scoop makes the mvn and gradle commands available globally. Scoop controls the system paths. These tools use the Java version that you selected with the scoop reset command.
Step 6: Automated environment variables
Many frameworks, Integrated Development Environments (IDEs), and build tools use the JAVA_HOME environment variable. This variable tells the tools where the compiler is.
When you install a JDK with Scoop, Scoop creates the JAVA_HOME environment variable. This variable points to a current symlink directory:
C:\Users\<YourUser>\scoop\apps\<jdk-package-name>\current
The scoop reset command
The JAVA_HOME variable points to the Scoop symlink. You do not change your system environment variables again.
- When you run
scoop reset openjdk17, Scoop changes the shortcut to point to the Java 17 directory. - Any IDE or tool that uses
JAVA_HOMEadapts to Java 17 when it reads the directory.
Step 7: Configure your IDEs
To make sure that your IDEs use your Scoop configuration, follow these steps.
IntelliJ IDEA
IntelliJ can detect installed SDKs. Point IntelliJ to the active directory of Scoop to keep your projects dynamic.
- Go to File, Project Structure, and Project.
- In the SDK section, click the dropdown list.
- Select Add SDK, and then select JDK.
- Go to your user directory:
C:\Users\<YourUser>\scoop\apps\openjdk\current. - Select the
currentfolder. IntelliJ uses the Java version that you select with thescoop resetcommand.
Visual Studio Code
If you use the Extension Pack for Java, you must tell VS Code where your Java runtimes are.
Press
Ctrl + Shift + Pto open the command palette.Select Preferences: Open User Settings (JSON). This opens your
settings.jsonfile.Add the
java.jdt.ls.java.homekey to the file.Set the value to your active Scoop symlink:
"java.jdt.ls.java.home":"C:/Users/<YourUser>/scoop/apps/openjdk/current"
- Replace
<YourUser>with your Windows username. Use forward slashes (/).
Troubleshooting and tips
Terminal restart
If you use Command Prompt (cmd.exe) or an IDE terminal, you must restart your terminal window. Do this after you switch Java versions. PowerShell sessions usually update without a restart.
Global installations
If you want Java available for all Windows user accounts, install it globally.
Open your terminal as an Administrator.
Add the
-gflag to your command:
scoopinstall-gopenjdk17scoopreset-gopenjdk17