How to Change Java Version in Windows 10

To change the Java version on Windows 10, install the JDK version you need, then point Windows at it: set the JAVA_HOME environment variable to the new JDK folder and move %JAVA_HOME%\bin to the top of your Path. Open a new Command Prompt and run java -version to confirm. IDEs such as IntelliJ IDEA, Eclipse, and VS Code can use a different JDK per project, so you may also need to change it there.

Step 1: Check Which Java Version Windows Uses Now

Open Command Prompt and run:

  • java -version shows the version that runs when you type java.
  • where java lists every java.exe on your Path, in the order Windows checks them. The first one wins.
  • echo %JAVA_HOME% shows the JDK folder that build tools like Maven and Gradle use.

If where java lists C:\Program Files\Common Files\Oracle\Java\javapath first, an Oracle installer added a shortcut folder that will keep overriding your choice until you move it down or remove it from Path.

Step 2: Install the JDK Version You Need

Download a JDK from a trusted source, such as Eclipse Temurin (Adoptium), the Microsoft Build of OpenJDK, Amazon Corretto, or Oracle. Choose the Windows x64 MSI installer for the major version you need, such as 17, 21, or 25. Several JDKs can be installed side by side; each goes into its own folder, for example C:\Program Files\Eclipse Adoptium\jdk-21.0.x-hotspot. Some installers, including Temurin’s, offer options to set JAVA_HOME and update Path for you. For step-by-step installer screens, see how to install the JDK on Windows 10 or how to get Java for Windows 10.

Step 3: Set JAVA_HOME

For a general walkthrough of this dialog, see how to set environment variables in Windows 10.

  1. Press Windows + S, type environment variables, and choose Edit the system environment variables (or Edit environment variables for your account if you do not have admin rights).
  2. Select Environment Variables.
  3. Under System variables (or User variables), select New, or select JAVA_HOME and Edit if it exists.
  4. Set the name to JAVA_HOME and the value to the JDK folder, without \bin. Use Browse Directory to avoid typos.
  5. Select OK.

Step 4: Update Path

  1. In the same window, select Path and choose Edit.
  2. Select New and enter %JAVA_HOME%\bin.
  3. Use Move Up to put it above any other Java entries, including the Oracle javapath folder.
  4. Remove entries that point to old JDK folders you no longer use.
  5. Select OK in every window.

Note that Windows checks the System Path before the User Path, so a Java entry in System Path will win over one in your User Path.

Step 5: Verify the Change

Close every open Command Prompt, PowerShell, and terminal window (including terminals inside your IDE), then open a new one and run java -version and where java. Already-open windows keep the old settings. If something still uses the old version, sign out and back in.

Switch Java Versions Temporarily

To use a different JDK for one terminal session only, run these lines in Command Prompt, changing the folder to your JDK:

set "JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-17.0.x-hotspot"

set "PATH=%JAVA_HOME%\bin;%PATH%"

The change lasts until you close that window. You can save these lines in small .bat files, such as java17.bat and java21.bat (see how to create a batch file), to switch quickly. In PowerShell, use $env:JAVA_HOME and $env:Path instead.

Change the Java Version in Your IDE or Build Tool

  • IntelliJ IDEA: File > Project Structure > Project > SDK. Gradle projects also have a Gradle JVM setting under Settings > Build Tools > Gradle.
  • Eclipse: Window > Preferences > Java > Installed JREs to add JDKs, then set the compiler compliance level per project.
  • VS Code: run Java: Configure Java Runtime from the Command Palette.
  • Maven: uses JAVA_HOME. Set the compiler release in pom.xml to target an older version while building with a newer JDK.
  • Gradle: uses JAVA_HOME by default, but Java toolchains in build.gradle can select a specific version automatically.

Troubleshooting

java -version still shows the old version

Another java.exe appears earlier in Path. Run where java, then move or delete the earlier entry, usually the Oracle javapath folder or an old JDK in System Path.

“‘java’ is not recognized”

Path does not include the JDK’s bin folder, or JAVA_HOME has a typo. Check the folder exists and that the Path entry is exactly %JAVA_HOME%\bin.

Maven or Gradle uses a different version than the terminal

Build tools read JAVA_HOME, not Path. Make sure JAVA_HOME matches the JDK you want, and check for a Gradle toolchain or IDE setting overriding it.

An application needs an older Java

Leave the system default on your main version and start that program with the full path to the older java.exe, or use its own configuration file to point at the older JDK.

Frequently Asked Questions

Can I have multiple Java versions installed?

Yes. JDKs install into separate folders, and you choose which one is active with JAVA_HOME and Path.

Should I uninstall old Java versions?

Remove versions you no longer need, especially outdated ones, but first check that no application or project depends on them.

Do I need to restart Windows?

No. Opening a new terminal is enough in most cases.

Does this work on Windows 11?

Yes, the steps are the same. Windows 10 reached end of support on October 14, 2025.

Get Our Free Newsletter

How-to guides and tech deals

You may opt out at any time.
Read our Privacy Policy