On this page, we will learn how to set the JAVA_HOME environment variable on Windows operating system. The JAVA_HOME environment variable is referred to in many scripts that support Java, servers, and other applications.
We can perform this setup during the Java installation process.
Java JDK Download
Identify JDK directory
Identify the JDK directory path on your computer to set it as the Java home environment variable. In-case of multiple JDK installations, it’s recommended to choose the latest version as the Java home.
Launch Control Panel >> System and Security>> System.
Click on Advanced System Settings >> Environment Variables.
Click on the New Environment variable and set the JAVA_HOME variable.
Click on the OK button to save the variable. Close the control panel.
Open the command prompt and type the following command to verify the variable.
/> echo %JAVA_HOME%
The command should display the JDK directory path to the console.
It is important to set this variable for the smooth running of Java dependent applications. For example, Tomcat Server start failed because of the Java_home environment variable not set.