Search code examples
javaenvironment-variablesjava-home

JAVA_HOME meaning


Why does ActiveMQ provider needs JAVA_HOME env variable to be set to a jdk location.
What does it use that variable for?
If it needs to run java command and relating commands, why bother with JAVA_HOME.
If PATH env variable is set correctly, java command is always available.

Or am I missing some points?

EDIT: I don't think my question is a duplicate, I'm asking pretty precise points on that variable, also in correlation to $PATH env variable and ActiveMQ.


Solution

  • The actual REASON for the JAVA_HOME is that many apps need to find more than just executables in the path, some java apps need to find the jar file they are supposed to use as a library -- Remember that there may be more than one java installation installed and that any given app may want a specific java version that isn't the one on the path.

    Consider an app that uses a specific version of java that isn't on the path. You can specify a path to the java.exe, but how does the app know which set of libraries it's supposed to be using if it needs to interact with them in some way other than just using them? It could probably figure it out from the environment, but might be inaccurate and would definitely be platform dependent.

    There is usually more than one way to set give the app this information, JAVA_HOME is one, often they don't need it at all.