2

What is the point of setting JAVA_HOME environmental variable when the only thing you have to set is the Path variable to call java from the command line, which is the primary purpose, right ?

Shady Programmer
  • 794
  • 4
  • 9
  • 22

3 Answers3

3

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

You could also use JAVA_HOME to set the PATH variable, something like this..

%JAVA_HOME%\bin;

So that you dont have to meddle with PATH variable every time, if you have to switch between two JDKs or two JREs of different versions

codeMan
  • 5,730
  • 3
  • 27
  • 51
2

Some application takes JAVA_HOME to execute/configure themselves instead of using the java executable in the PATH: tomcat, maven, weblogic, eclipse, etc...

So it's a good idea to have this variable properly set.

jfcorugedo
  • 9,793
  • 8
  • 39
  • 47
1

IMO this is a unix thing where the OS's files are saved. Windows is totally different. But since Java is installed into Program files in Windows it doesn't make sense either.

Micromega
  • 12,486
  • 7
  • 35
  • 72