title: Reliable way to find JRE installation in Windows bat file to run java program
body: <p>When installing the latest JRE 7 on Windows, it no longer adds the command <code>java</code> to the system path. So just calling <code>java --version</code> in bat file fails in that case (despite that Java from java.com is installed).</p>
  
  <p><strong>What's a reliable way to find the java command installation directory in a windows bat file?</strong></p>
  
  <p>I've seen it in the following locations:</p>
  
  <ul>
  <li><code>C:\Program Files\Java\jre6\bin\java.exe</code></li>
  <li><code>C:\Program Files\Java\jre7\bin\java.exe</code></li>
  <li><code>C:\Program Files (x86)\Java\jre7\bin\java.exe</code></li>
  <li>Not tried JRE 8 yet.</li>
  </ul>
  
  <p>Note: if there are multiple, I 'd like the default (or the latest - I don't care).</p>