WinAPI Java – How to Detect Installed Sun/Oracle JRE on Windows

javawinapi

I tried googling the answer, but all I found was tips on how to detect Java from a browser or the very generic way of just starting Java and see if it runs, which introduces a possibly long delay in my application. (~ two seconds when started the very first time on my machine)

I hope there is a faster way, if the following restrictions apply:

  • Only Sun/Oracle JREs or JDKs
  • Only 1.6 and higher
  • Only Windows platforms
  • Not from a browser, but from a plain old Win32 executable

This detection is not meant for a public application, but for internal use on Windows platforms only.

Is there a registry path I can read or some configuration file I can parse?

Best Answer

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment