These third-party programs make use of the environment variables that point to the directory of JDK or JRE. In simple words, it makes easy for the programs to locate the directory executable like javac in the computer. If you are not using these third-party programs, then it may not be mandatory for users to set up JAVA_Home in your system. In this article, we will explain in detail how to set JAVA_HOME as the environment variable in Windows 10.

Setting JAVA_HOME in Windows 11/10

Set JAVA_HOME environment variable & update the system path

Download and install Java from the official site – java.com. After installation, Go to Start menu and type Advanced system settings. Click on View advanced system settings from the list to open System Properties. Go to Advanced tab and click on Environment Variables button.

In the Environment Variable window, click on New button under the System variable. In the Edit System Variable, give the Variable name as JAVA_HOME and Variable value as the path to your JDK directory.

Click on OK. Now go back to the Environment Variable window and select Path under the System variable.

Click on Edit button to open Edit environment variable window.

Click on New button and type  %JAVA_HOME%\bin.

Click OK to apply the changes.

Check JAVA_HOME configuration setup using CMD

To test your configuration, open Command prompt. Type echo %JAVA_HOME% and hit Enter. This should print the directory of the JDK which the JAVA_HOME is pointing. Instead, if you see a space, it means you have failed in setting up environment variable.

Next Type javac -version which should print the version of Java compiler.

If not it will print a message that the javac is not recognized as an internal or external command. This means the path variable is not set correctly. Hope this helps!