Setting JAVA_HOME

The JAVA_HOME environment variable plays a special role in Java. Even though the JVM executable, java.exe or java, is on the PATH (thus, you can execute it by typing the name java without specifying the directory in the Command Prompt) (Terminal), it is recommended that you use the correct Java installation to set this environment variable. The value of the variable should point to the installed JDK. There are many Java-related programs, Tomcat or Maven for example, that use this variable to locate the installed and currently used Java version. In macOS, setting this variable is unavoidable.

In macOS, the program that starts to execute when you type java, is a wrapper that first looks at JAVA_HOME to decide which Java version ...

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.