Java is a popular programming language that is widely used in enterprise applications, web development, and Android app development. To work with Java, it is essential to set up the JAVA_HOME environment variable on your computer. This blog post will guide you through the process of setting up JAVA_HOME in Windows 10.
Before you begin, make sure you have the following installed on your computer:
- Java Development Kit (JDK) – You can download the latest version from the Oracle website.
Setting up JAVA_HOME
Follow these steps to set up JAVA_HOME on your Windows 10 machine:
Step 1: Locate your JDK installation directory
First, you need to find the JDK installation directory on your computer. The default path is usually:
Where jdk-version is the installed JDK version, such as jdk-14.0.2.
Step 2: Open Environment Variables settings
1. Right-click on the Start button and select System.
2. In the System settings window, click on Advanced system settings on the right side.
3. In the System Properties window, click on the Environment Variables button at the bottom right corner.
Step 3: Create a new JAVA_HOME variable
1. In the Environment Variables window, under the System variables section, click on the New button.
2. In the New System Variable window, enter JAVA_HOME as the Variable name and the path to your JDK installation directory as the Variable value (e.g., C:\Program Files\Java\jdk-14.0.2).
3. Click OK to save the new variable.
Step 4: Update the PATH variable
1. In the Environment Variables window, under the System variables section, find and select the Path variable, then click on the Edit button.
2. In the Edit environment variable window, click on the New button and add the following:
3. Click OK to save the changes.
Step 5: Verify the JAVA_HOME setup
1. Open a new Command Prompt window. (Make sure to close any existing Command Prompt windows for the changes to take effect.)
2. Type the following command and press Enter:
You should see the path to your JDK installation directory as output. For example:
3. Now, check if Java is correctly added to the Path by running the following command:
If everything is set up correctly, you should see the installed Java version as output.
Congratulations! You have successfully set up the JAVA_HOME environment variable on your Windows 10 machine. You can now develop and run Java applications on your computer. Happy coding!