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:
- Right-click on This PC and select Properties.
- Click on Advanced system settings on the left side of the System window.
- In the System Properties window, click on the Environment Variables button.
- Under the System variables section, click on the New button.
- 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)
- 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:
- Open the Environment Variables window, as described in Step 1.
- Find the PATH variable in the System variables section and select it.
- Click on the Edit button.
- In the Edit environment variable window, click on the New button and add the path to the JDK’s bin directory: %JAVA_HOME%\bin
- 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:
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.