title: How to detect presence and location of JVM on Windows?
body: <p>I'm trying to detect if there is a JVM installed and where it is located so I can run <code>java.exe</code>.</p>
  
  <p>All I've managed to find is <code>HKCU\Software\JavaSoft\Java Runtime Environment\&lt;ver&gt;</code>. Is it safe to assume that it is installed in <code>%PROGRAMFILES%\Java\jre&lt;ver&gt;</code>?</p>
  
  <p>I'm trying to do this in C#, but I assume the answer is pretty language agnostic, so any answer is appreciated.</p>
  
  <p><strong>EDIT:</strong> Ok silly me, I found <a href="https://stackoverflow.com/questions/1855937/how-to-detect-whether-java-runtime-is-installed-or-not-on-a-computer-using-c">How to detect whether java runtime is installed or not on a computer using c#</a> which pointed me at <code>HKLM\Software\JavaSoft\Java Runtime Environment\CurrentVersion</code> which works with <code>HKLM\Software\JavaSoft\Java Runtime Environment\&lt;ver&gt;\JavaHome</code>. I managed to find these instead underneath <code>HKLM\Software\Wow6432Node\JavaSoft\Java Runtime Environment</code>. Is there some way to detect which of these I should be checking without trying to sniff at the CPU type?</p>