Setting the JAVA_HOME Variable in Windows
Set the JAVA_HOME Variable
To set the JRE_HOME or JAVA_HOME variable:
Locate your Java installation directory
If you didn't change the path during installation, it'll be something like
C:\Program Files\Eclipse Adoptium\jdk-18.104.22.168-hotspot\or
You can also type
where javaat the command prompt.
- Do one of the following:
Windows 7 – Right click My Computer and select Properties > Advanced
Windows 8 – Go to Control Panel > System > Advanced System Settings
Windows 10 – Search for Environment Variables then select Edit the system environment variables
- Click the Environment Variables button.
- Under System Variables, click New.
- In the Variable Name field, enter either:
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.
- Click OK and Apply Changes as prompted
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 after reopening the command window, restart Windows.
Set the JAVA_HOME variable via the command line
If you would prefer to set the JAVA_HOME (or JRE_HOME) variable via the command line:
- Open Command Prompt (make sure you Run as administrator so you're able to add a system environment variable).
Set the value of the environment variable to your JDK (or JRE) installation path as follows:
setx /m JAVA_HOME "C:\Program Files\Java\jdk22.214.171.124"
Restart Command Prompt to reload the environment variables then use the following command to check the it's been added correctly.
You should see the path to your JDK (or JRE) installation.
Was this helpful?Yes Provide feedback about this article