Set the Java_Home Variable In Windows 10
This article will guide you How to set java_home variable classpath in Windows 10!
Note: This can be implemented in Windows 8.1, Windows 8 and Windows 7 too.
” JAVA_HOME ” is an environment variable (in Unix terminologies), or a PATH variable (in Windows terminology).
Many Java applications that require the JDK/JRE to run, look up the JAVA_HOME variable for the location where the Java compiler/interpreter may be found.
After you’ve installed Java JRE or JDK in Windows, you must set the ”
JAVA_HOME” environment variable to point to the Java installation directory.
What are the 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 does a search for the ”
CLASSPATH” entries 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 Windows 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-13.0.2
- In the desktop right-click My Computer/This PC/ or open Explorer and select Properties > Advanced.
You can also go to 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,
For example: C:\Program Files\Java\jdk-9\13.0.2)
- Click OK and Apply Changes as prompted.
Note for Windows users on 32-bit & 64-bit systems
Progra~1 = ‘Program Files’ //This is for 64bit users
Progra~2 = ‘Program Files(x86)’ // This is for 32bit users
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.