If you are getting an error while you are trying to run your Java program/application. Then this may be because you have not set up Java JDK properly on your Windows 10 computer.
By just downloading and installing Java will not work, we have to set the JAVA_HOME environment variable. JAVA_HOME is the name of an environment variable on the operating system that points to the installation directory of Java JDK.
How to Setup JAVA_HOME Variable on Windows 10
In this section, we are going to discuss how we can set up the JAVA_HOME environment variable on windows 10. Here you’ll also find a video tutorial:
Step 1: First of all, you have to download and install Java JDK on your windows 10 computer.
Step 2: After that open a control panel and go to System and Security > System > Advanced system settings.
Step 3: In System Properties window go to Advanced Tab and click on “Environment Variable“.
Step 4: Under the “System variables” click the “New” button and enter JAVA_HOME as a variable name and the path to your Java JDK directory under Variable value.
Step 5: Now you have to add this JAVA_HOME variable to the Path. Click on “Path” then click on “Edit” and add a new environment variable “%JAVA_HOME%\bin”
How to Verify JAVA_HOME Variable
Now to verify the JAVA_HOME environment variable open command prompt and run this command.
This will show you the java version, Java SE Runtime Environment and Java HotSpot Server VM build number.
This will print out the directory JAVA_HOME points to or empty line if the environment variable is not set correctly.
Now to check javac compiler just run this command
If you find a bunch of statements in the command prompt that means JAVA_HOME is fully set up on your windows system.