Skip to content

How to Install the Latest Java Version on Windows

This guide provides step-by-step instructions for installing the latest version of Java on a Windows machine, covering both cases where you have administrative privileges and when you do not. It also includes details on updating the environment variables after installation.

1. Check Your Current Java Version

Before installing Java, check if you already have a version installed. Open Command Prompt (cmd) or PowerShell and type:

java -version
If Java is installed, it will display the version. If not, you will see an error message.

2. Download the Latest Java Version

Visit the official Oracle JDK download page: - Oracle Java Downloads - Alternatively, you can use OpenJDK: Adoptium

Choose the appropriate JDK installer for Windows.

3. Installing Java with Admin Rights

If you have administrative privileges, follow these steps: 1. Run the Installer: Double-click the .exe installer and follow the prompts. 2. Select Installation Path: By default, Java installs in C:\Program Files\Java\jdk-<version>. 3. Complete Installation: Click ‘Next’ and finish the installation.

Updating Environment Variables (Admin Method)

  1. Open the Start Menu, search for Environment Variables, and select Edit the system environment variables.
  2. Click Environment Variables.
  3. Under System Variables, find Path, select it, and click Edit.
  4. Click New and add the Java bin directory path (e.g., C:\Program Files\Java\jdk-<version>\bin).
  5. Set the JAVA_HOME variable:
  6. Click New under System Variables.
  7. Set JAVA_HOME as the variable name and C:\Program Files\Java\jdk-<version> as the value.
  8. Click OK to save changes.
  9. Open a new Command Prompt or PowerShell window and type:
    java -version
    
    to verify the installation.

4. Installing Java Without Admin Rights

If you do not have administrative privileges, follow these steps:

  1. Download the ZIP version of the JDK from Adoptium or Oracle.
  2. Extract the ZIP to a folder where you have write access, e.g., C:\Users\YourUsername\Java\jdk-<version>.

Updating Environment Variables (User Method)

  1. Open Start Menu, search for Environment Variables, and select Edit the environment variables for your account.
  2. Under User Variables, find Path, select it, and click Edit.
  3. Click New and add the Java bin directory path, e.g., C:\Users\YourUsername\Java\jdk-<version>\bin.
  4. Set JAVA_HOME:
  5. Click New under User Variables.
  6. Set JAVA_HOME as the variable name and C:\Users\YourUsername\Java\jdk-<version> as the value.
  7. Click OK to save changes.
  8. Restart Command Prompt or PowerShell and verify by running:
    java -version
    

5. Running Java Without Setting Environment Variables

If you do not want to set up environment variables, you can still run Java manually from the extracted folder: 1. Navigate to the extracted JDK folder where java.exe is located. 2. Open Command Prompt or PowerShell and type the full path to the Java binary:

C:\Users\YourUsername\Java\jdk-<version>\bin\java -version
3. To run a Java application directly from the downloaded binary, use:
C:\Users\YourUsername\Java\jdk-<version>\bin\java -jar C:\Users\YourUsername\Downloads\runsomething.jar
or if you're in the folder where Java is located:
./Downloads/java -jar runsomething.jar

6. Verifying Java Installation

After setting the environment variables, confirm that Java is correctly installed by running:

java -version
If the correct version is displayed, your installation is complete!

Additional Notes

  • If multiple versions of Java exist on your system, ensure the correct one appears first in the Path variable.
  • To switch Java versions, adjust the JAVA_HOME variable accordingly.
  • Consider using a Java version manager like jEnv (for Windows Subsystem for Linux) or SDKMAN! (on Windows via WSL) for managing multiple Java versions efficiently.