I would like to know what is JAVA_HOME. 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 prom
use this command /usr/libexec/java_home to check the JAVA_HOME
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.
JAVA_HOME
and JRE_HOME
are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK
or JRE
. If you are not using software that requires them, you do not need to set JAVA_HOME
and JRE_HOME
.
PATH
is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin
subdirectory of your JDK
installation directory to the PATH
, so that you can use the javac
and java
commands and other JDK
tools in a command prompt window. Courtesy: coderanch
The command prompt wouldn't use JAVA_HOME to find javac.exe, it would use PATH.
JAVA HOME
is used for setting up the environment variable for JAVA. It means that you are providing a path for compiling a JAVA program and also running the same. So, if you do not set the JAVA HOME( PATH ) and try to run a java or any dependent program in the command prompt.
You will deal with an error as
javac : not recognized as internal or external command
.
Now to set this, Just open your Java jdk then open bin folder then copy the PATH of that bin folder.
Now, go to My computer right click on it----> select properties-----> select Advanced system settings----->Click on Environment Variables------>select New----->give a name in the text box Variable Name and then paste the path in Value.
That's All!!
JAVA_HOME is an Environment Variable set to the location of the Java directory on your computer. PATH is an internal DOS command that finds the /bin directory of the version of Java that you are using. Usually they are the same, except that the PATH entry ends with /bin