title: Check Java is present before installing
body: <p>I'm creating an Inno Setup installer for a jar app.
  What I want to do right now is to check if java is present before proceeding with the install. So I only need to be sure the users will be able to run:</p>
  
  <pre><code>java -jar my-app.jar
  </code></pre>
  
  <p>What I'm doing right now is:</p>
  
  <pre class="lang-pascal prettyprint-override"><code>[Code]
  
  function InitializeSetup(): Boolean;
  var
    ErrorCode: Integer;
    JavaInstalled : Boolean;
    Result1 : Boolean;
  begin
    JavaInstalled := RegKeyExists(HKLM,'SOFTWARE\JavaSoft\Java Runtime Environment\1.6');
    if JavaInstalled then
    begin
      Result := true;
    end else
      begin
        Result1 := MsgBox('This tool requires Java Runtime Environment version 1.6 or newer to run. Please download and install the JRE and run this setup again. Do you want to download it now?',
          mbConfirmation, MB_YESNO) = idYes;
        if Result1 = false then
        begin
          Result:=false;
        end else
        begin
          Result:=false;
          ShellExec('open',
            'http://javadl.sun.com/webapps/download/AutoDL?BundleId=33787',
            '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
        end;
      end;
    end;
  end;
  </code></pre>
  
  <p>My questions are:</p>
  
  <ul>
  <li><p>Is checking the registry enough to be sure java's home dir will be in the PATH? (to be able to run "java" in the console)</p></li>
  <li><p>If a higher version of java is installed, will that key in the registry exist anyway or I will have to check for each higher version possible?</p></li>
  <li><p>Does anyone have a better way to download java than just showing a popup and taking the users to the download page?</p></li>
  </ul>