Setting the Java_Home Variable In Windows 10: This can be followed in Windows 8 and Windows 7 too.
This article will guide you How to set java_home variable classpath in Windows 10.
JAVA_HOME is an environment variable (in Unix terminologies), or a PATH variable (in Windows terminology). A lot of well behaving Java applications (which need the JDK/JRE) to run, looks up the JAVA_HOME variable for the location where the Java compiler/interpreter may be found.
After you’ve installed Java in Windows, you must set the ”
JAVA_HOME” environment variable to point to the Java installation directory.
What are Environment Variables?
Environment variables are global system variables accessible by all the processes running under the Operating System (OS). Environment variables are useful to store system-wide values such as the directories to search for the executable programs (
PATH) and the OS version. Examples of environment variables in Windows OS are:
USERNAME: stores the computer and current username.
OS: the operating system.
SystemRoot: the system root directory.
PATH: stores a list of directories for searching executable programs.
In setting up JDK and Java applications, you will encounter these environment variables:
PATH: maintains a list of directories. The OS searches the
PATHentries for executable programs, such as Java Compiler (
javac) and Java Runtime (
CLASSPATH: maintain a list of directories (containing many Java class files) and JAR file (a single-file archive of Java classes). The Java Compiler and Java Runtime searches the
CLASSPATHentries for Java classes referenced in your program.
JRE_HOME: maintain the locations of JDK and JRE installed directory, respectively.
This information is only relevant if you’ve installed Java JDK or Java JRE in Windows.
There are two scenarios:
- If you installed the Java Development Kit (JDK) you’ll be setting the
- If you installed the Java Runtime Environment (JRE) you will follow the same steps but set the
JRE_HOMEenvironment variable instead.
Procedure to Set the JAVA_HOME Variable in Window 10.
We are assuming that you have a 64-bit system and a 64bit Windows Operating System. For example; Windows 10 64bit.
To set the JAVA_HOME variable:
- Find out where Java is installed. If you didn’t change the path during installation, it would be something like this: C:\Program Files\Java\jdk-9.0.1
- In the desktop right-click My Computer/This PC/ or open Explorer and select Properties > Advanced.
You can also goto Control Panel > System > Advanced System Settings.
- Then Click the Environment Variables button.
- There will be System Variables; now under System Variables click New.
- In the Variable Name field, enter:
JAVA_HOMEif you installed the JDK (Java Development Kit)
JRE_HOMEif you installed the JRE (Java Runtime Environment)
- In the Variable Value field, enter your JDK or JRE installation path.If the path contains spaces, use the shortened pathname,
- Click OK and Apply Changes as prompted.
Finally, you’re done. To observe any effect, you’ll need to close and re-open any command windows that were open before you made these changes.
As there’s no way to reload environment variables from an active command prompt. If the changes don’t take effect even after reopening the command window, restart Windows.
Thanks for reading this tutorial. If you have any questions, you can ask me in the comments section below.