JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed. This variable should be configured on all OS's that have a Java installation, including Windows, Ubuntu, Linux, Mac and Android. 

The JAVA_HOME environment variable is not actually used by the locally installed Java runtime. Instead, other programs installed on a desktop computer that require a Java runtime will query the OS for the JAVA_HOME variable to find out where the runtime is installed. After the location of the JDK or JRE installation is found, those programs can initiate Java-based processes, start Java virtual machines and use command line utilities such as the Java archive utility or the Java compiler, both of which are packaged inside the Java installation's \bin directory.

How to set JAVA_HOME on Windows

A user can set JAVA_HOME on Windows through the administrative option in the "Edit System Variables" window. With the environment variables editor, a user can add a new system variable named JAVA_HOME and assign it the value of the location of the JDK install directory. 

How to find JAVA_HOME

It is important for a user to easily find the JAVA_HOME value and verify that it is set properly. One way to find JAVA_HOME is to open the environment variable editor and view its assigned value. Another option is to echo JAVA_HOME in a command window.  

Programs that get JAVA_HOME on startup

Any Java-written program will require a Java-based environment in which to run. Programs that require the JAVA_HOME variable to be configured properly include:

  • Eclipse, NetBeans and Android Studio
  • Apache Tomcat and WebSphere Portal
  • JProfiler and Java Mission Control
  • Maven and ANT
  • Gradle and Groovy
  • Jenkins and Hudson CI tools
  • exe4j

Even video games like Minecraft, SimCity and some versions of Castlevania require JAVA_HOME to be configured.

Common JAVA_HOME errors

If any program that requires a Java runtime fails to find the JAVA_HOME environment variable upon startup, or if the JAVA_HOME environment variable is misconfigured, it will result in some of the following error messages to be displayed:

  • A Java installation exists but JAVA_HOME has been set incorrectly
  • JAVA_HOME is set to an invalid directory
  • JAVA_HOME is not defined correctly
  • JAVA_HOME environment variable is not set
  • JAVA_HOME command not found
  • JAVA_HOME not found in your environment
  • JAVA_HOME does not point to the JDK 

Most of these problems can be addressed once the user confirms that the JAVA_HOME variable has indeed been set up and that the variable has been assigned the correct value. 


Java runtime environments can be installed on a computer in one of two ways. The first way is to download and install the JRE, which is a Java runtime environment and nothing else. The second way is to download and install the JDK, which provides both a Java runtime along with a variety of tools that assist in software development.  Some programs require only the JRE to function, while others require a full JDK. Programs that only require the JRE will often look for a JRE_HOME, which will point to a JRE installation, rather than look for JAVA_HOME, which should point to a JDK install.

JAVA_HOME vs PATH Variable

Along with the configuration of JAVA_HOME, it is also useful to simultaneously update the operating system's PATH variable. With the PATH, the Java installation's \bin directory is added, which makes all of the various Java utilities packaged in a JDK or JRE available from anywhere on the command line. As a result, if a program cannot locate the JAVA_HOME variable, it may still be able to access Java runtime tools by looking at which utilities have been made available through the PATH.

This was last updated in July 2019

Continue Reading About JAVA_HOME

Dig Deeper on Core Java APIs and programming techniques

App Architecture
Software Quality
Cloud Computing