What is JAVA_HOME? How does the JVM find the javac path stored in JAVA_HOME?

java

Solution

JVM does not find `java.exe`. It doesn't even call it. `java.exe` is called by the operating system (Windows in this case).

`JAVA_HOME` is just a convention, usually used by Tomcat, other Java EE app servers and build tools such as `Gradle` to find where Java lives.

The important thing from your point of view is that the Java `/bin` directory be on your `PATH` so Windows can find the `.exe` tools that ship with the JDK: `javac.exe`, `java.exe`, `jar.exe`, etc.

Problem

I would like to know what JAVA_HOME is. Where do I set the path of javac.exe and java.exe. It is in environment variables? When I compile a Java program from command prompt, how does the JVM find `javac.exe`?

Original source

Related problems