In this guide, we will learn: How to Set JAVA_HOME Variable on Windows 11 – guide 2023
While running your Java program/application, if you are getting a JAVA_HOME error. Then this may be because you have not set up the JAVA_HOME environment variable on your Windows 11. Here is a detailed guide on; how to set the JAVA_HOME variable on Windows.
JAVA_HOME is the name of an environment variable on the operating system that points to the installation directory of Java Runtime Environment or Java Development Kit. You can also check our guide on; how to install and set up Java JDK on Windows 11.
How to Setup JAVA_HOME Variable on Windows 10
By just downloading and installing Java, Java files will not work. You have to; set up the java environment variable and JAVA_HOME variable on your Windows 11. So, the system can execute java code on your Windows 11 system.
Step 1: First, you must download and install Java SE Development Kit on your system.
Step 2: After that, click on the “Start” button. Search for “edit the system environment variables” and open it.
Step 3: It will open the “System Properties“ window. Click on the “Advanced” tab and click the “Environment Variable” option.

Step 4: Under the “System variables“section, click the “New” button. Here, enter JAVA_HOME as a variable name and the installation directory of Java JDK under variable value. Then click on “OK” to save the changes.

Step 5: Now, go back to the “Environment Variable” window and select “Path” under the System variable. Then click on the “Edit” button.

Step 6: Here, you need to add the JAVA_HOME variable to the Path. For that, click on “New” and type %JAVA_HOME%bin
to add the new environment variable. After that, click on “OK” to save the changes.

How to Verify JAVA_HOME Variable
By following; the above steps, you can set the JAVA_HOME variable on your system. Now to verify the JAVA_HOME environment variable, follow the below steps:
Step 1: Click the “Start” button, search for “cmd,” and open the command prompt as administrator.

Step 2: Now run the following command:
echo %JAVA_HOME%

This command should print the directory of the Java JDK to which the JAVA_HOME is pointing. Or else, you will get an empty line if the JAVA_HOME variable is not configured correctly.
Step 3: Next, run the javac --version
command; to check the version of the Java compiler.

If everything went fine, that means; you have successfully set the JAVA_HOME on Windows 11.
Conclusion
That’s it; this is how you can set the JAVA_HOME variable on Windows 11. You can also check our detailed guide on; how to install and set up Eclipse IDE on Windows 11 for Java programming.
I hope this article was helpful to you. If you liked the article, share it with your friends and family. If you have some suggestions, do not hesitate to leave them in the comments section below.
If this guide helped you, please share it. 🙂