title: What is the difference between the JAVA_HOME environment variable and the output of "java -version"
body: <p>What is the JAVA_HOME environment variable actually? I'm in doubt. What is done by setting it ? And I have also another question that if we have two or more JDK s in the OS, we can set one version's path to set the $JAVA_HOME variable and another version as the running java in the machine which is shown by "java -version" command.As I think in ubuntu, java --version command gives the JRE configured (running java) version of java and JAVA_HOME variable defines which version to use for compiling java programs. Am I correct? What is actually the difference between the jdks referred by these two outputs-</p>
  
  <pre><code>    1. echo $JAVA_HOME 
      2. java -version
  </code></pre>