Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To update Java from Windows 11 Command Prompt, first run winget upgrade and identify whether your installed Java distribution is listed. Upgrade it using its exact package ID, or use that vendor’s installer if WinGet does not manage it. Then open a new CMD window and check java -version; if it still shows the old version, inspect which Java executable comes first in PATH.

1. Check the Java version currently in use

Open Command Prompt and run:

java -version
javac -version
where java
echo %JAVA_HOME%

java -version reports the runtime selected by the current terminal. If you need Java development tools, javac -version checks whether a JDK compiler is available. Someone who only runs an application may need the runtime required by that application. where java lists matching executables found through PATH; the first result normally takes precedence.

For example, results may show Java installations in different directories. Check the actual paths on your PC; do not assume that a particular vendor or version is active. Changing JAVA_HOME alone does not necessarily change which executable CMD finds first.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Find available WinGet upgrades

In CMD, run:

winget upgrade

Review the results for your installed Java distribution and its package ID before upgrading. You can also search the catalog, for example:

winget search OpenJDK
winget search Temurin

Microsoft documents these example package IDs:

Distribution Example WinGet package ID
Microsoft Build of OpenJDK 21 Microsoft.OpenJDK.21
Eclipse Temurin 21 JDK EclipseAdoptium.Temurin.21.JDK

These examples do not establish which package or version is installed on your computer. Oracle JDK, Azul Zulu, Amazon Corretto, and manually installed JDKs may require their own update route. Microsoft says, “For most developers, Microsoft Build of OpenJDK or Temurin are good choices.” See Microsoft’s Java on Windows guide.

3. Upgrade the matching distribution with WinGet

When WinGet lists the installed package, use its ID and exact match. For the documented Microsoft Build of OpenJDK 21 example, run:

winget upgrade –id Microsoft.OpenJDK.21 –exact

For the documented Temurin 21 JDK example, run:

winget upgrade –id EclipseAdoptium.Temurin.21.JDK –exact

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the ID and feature version that match your installation and the requirements of your project or application. Do not assume that upgrading Java means changing to a different feature version. If WinGet reports no applicable upgrade, the package may already be current or the installation may not be managed by WinGet. Installing a package with winget install is not the same as upgrading the package already installed.

4. Use the vendor installer if WinGet does not manage Java

If WinGet does not list the installed distribution, follow that JDK vendor’s current release instructions. Oracle documents a Windows MSI installation route that can be launched from an administrator Command Prompt. After downloading the appropriate MSI, the command pattern is:

msiexec.exe /i jdk-<version>_windows-x64_bin.msi

Replace the placeholder with the actual installer filename and follow Oracle’s release-specific directions and applicable terms. The Oracle guide describes administrator permissions and additional silent-install options. Installing a new JDK does not necessarily remove older versions or make CMD select the new one. See Oracle’s Windows JDK installation guide.

5. Verify the selected version

Close the current CMD window, open a new one, and run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

java -version
javac -version
where java

A new terminal picks up current environment settings. If the version is still old, use where java to inspect the executable paths. When multiple JDKs are installed, PATH order determines which Java CMD runs first.

6. Correct JAVA_HOME and PATH if needed

Set JAVA_HOME to the intended JDK root folder, not its bin folder. Then ensure the JDK’s bin folder is included in PATH. For developer tools, Microsoft’s guidance notes that JAVA_HOME must be set manually on Windows.

  1. Open Start and search for Environment Variables.
  2. Select Edit the system environment variables, then choose Environment Variables.
  3. Create or edit JAVA_HOME and set its value to the JDK root directory, using the actual folder installed on your PC.
  4. Edit the applicable Path variable and add %JAVA_HOME%\bin.
  5. Move that entry ahead of older Java bin entries if you want this JDK to take precedence, then confirm the dialogs.
  6. Open a new CMD window and check echo %JAVA_HOME%, java -version, and where java.

JAVA_HOME and PATH serve related but distinct purposes: developer tools may consult JAVA_HOME, while CMD resolves the java command according to PATH order.

Choose the right update path

Path Use when Check
WinGet upgrade WinGet recognizes the installed distribution Run winget upgrade, confirm the package ID and feature version, then upgrade that package.
Vendor installer WinGet does not manage the installation or vendor instructions call for an installer Get the current release installer and follow vendor instructions; Oracle’s documented MSI route requires an administrator Command Prompt.
PATH and JAVA_HOME correction Installation completed but CMD or developer tools resolve an unexpected Java Check where java, PATH order, and JAVA_HOME, then open a new terminal.

Common problems

Symptom What to check
WinGet does not list Java The installation may not be managed by WinGet. Use the vendor’s installer or update guidance.
WinGet reports no applicable upgrade Check whether the package is already current and whether the listed package ID matches the installed distribution.
java -version still shows an older version Run where java and check whether an older Java bin folder appears first in PATH.
javac is not recognized A JDK compiler may not be installed or its bin folder may not be in PATH. Check whether your task requires a JDK.
An application stops working after an update Check the application’s Java feature-version and vendor requirements before changing the selected JDK.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

FAQ

What CMD command should I use to update Java?

Run winget upgrade first, identify the installed distribution’s package ID, then use winget upgrade –id <package-id> –exact. If WinGet does not manage the installation, use the vendor’s current installer instructions.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How can I see which Java version CMD is using?

Run java -version. To check the compiler for a JDK, run javac -version. Use where java to see the executable paths CMD can find.

Why does CMD still show the old Java version?

An older Java executable may appear earlier in PATH. Check the results of where java, correct PATH order if needed, and open a new CMD window.

Does changing JAVA_HOME change the Java command in CMD?

Not necessarily. JAVA_HOME is an environment setting often used by developer tools; CMD selects java according to PATH order. Set both as needed and verify with a new terminal.

Do I need to uninstall the old JDK?

Not necessarily. Multiple JDKs can be installed, but check PATH and application requirements so the intended version is selected. Remove an older installation only after confirming it is no longer needed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I update Oracle JDK with a Microsoft OpenJDK package ID?

No. A Microsoft OpenJDK package ID targets that distribution. Oracle documents its own Windows installation route, including MSI installation instructions.

The Bottom Line

Run winget upgrade to discover available package upgrades, confirm the installed Java distribution and package ID, then upgrade that exact package or follow the vendor’s installer instructions. Verify with java -version and where java; if CMD selects an older installation, correct PATH precedence and open a new terminal.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.