update java version windows 10 cmd

  1. Open the Command Prompt: Press Windows Key + X and select "Command Prompt" from the menu.

  2. Check the current Java version: Type java -version and press Enter. Note the current version.

  3. Download the latest Java version: Visit the official Oracle website or another trusted source, and download the latest Java Development Kit (JDK) for Windows.

  4. Uninstall the existing Java version: Type java uninstall in the Command Prompt and follow the prompts to uninstall the current Java version.

  5. Install the new Java version: Run the installer for the downloaded JDK, and follow the installation prompts.

  6. Set the new Java version as default: Type java -version to confirm the installation. If the new version is not displayed, update the system environment variables: a. Right-click on "This PC" or "Computer" and select "Properties." b. Click on "Advanced system settings." c. Click on the "Environment Variables" button. d. Under "System variables," find and select the "Path" variable, then click "Edit." e. Add the path to the new Java version's "bin" directory to the end of the existing values. For example, C:\Program Files\Java\jdk-15.0.1\bin. f. Click "OK" to close each window.

  7. Verify the Java version: Open a new Command Prompt window and type java -version again. The updated Java version should be displayed.

  8. Check the Java Compiler version: Type javac -version to verify the Java Compiler version. It should match the installed JDK version.

  9. Cleanup: Delete any unnecessary old Java installations from your system to free up space and avoid potential conflicts.