How To Java Environment Variables In Windows 10

Setting up Java environment variables is an essential step in the process of running and developing Java applications on your Windows 10 machine. In this blog post, we will guide you through the process of setting up your system to run Java applications with ease.


Before setting up the environment variables, you need to have the Java Development Kit (JDK) installed on your machine. If you haven’t already, you can download the JDK from the official Oracle website.

Step 1: Set JAVA_HOME Variable

The JAVA_HOME environment variable is used by many Java applications to find the JDK installation directory. To set the JAVA_HOME variable, follow the steps below:

  1. Right-click on This PC and select Properties.
  2. Click on Advanced system settings on the left side of the System window.
  3. In the System Properties window, click on the Environment Variables button.
  4. Under the System variables section, click on the New button.
  5. Enter the following details:
    • Variable name: JAVA_HOME
    • Variable value: C:\Program Files\Java\jdk1.8.0_291 (Replace this path with the path to your JDK installation)
  6. Click OK to save the new variable.

Your JAVA_HOME variable is now set.

Step 2: Update the PATH Variable

Adding the JDK’s bin directory to the system PATH will allow you to easily run Java commands from the command prompt. To update the PATH variable, follow these steps:

  1. Open the Environment Variables window, as described in Step 1.
  2. Find the PATH variable in the System variables section and select it.
  3. Click on the Edit button.
  4. In the Edit environment variable window, click on the New button and add the path to the JDK’s bin directory: %JAVA_HOME%\bin
  5. Click OK to save the changes.

Your PATH variable has now been updated to include the JDK’s bin directory.

Step 3: Verify the Java Environment Variables

To confirm that the Java environment variables have been set up correctly, open a new command prompt and enter the following command:

    java -version

You should see the version of the installed JDK displayed in the output:

    java version "1.8.0_291"
    Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

If you see the JDK version in the output, congratulations! Your Java environment variables are now set up properly, and you are ready to start developing and running Java applications on your Windows 10 machine.