Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect the installed Sun/Oracle JRE on Windows?

Tags:

java

winapi

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?

like image 706
Daniel Rikowski Avatar asked Aug 27 '09 09:08

Daniel Rikowski


People also ask

How do I know if JRE is installed on Windows?

You might have either JRE(Java Runtime Environment) which is required to run java applications on the computer or JDK as shown below. 1. Open command prompt and enter “java –version”. If installed version number is displayed.

Where can I find my JRE installed?

The default installation directory of a static JRE is C:\Program Files (x86)\Java\jre n (for 32-bit versions) or C:\Program Files\Java\jre n (for 64-bit versions), where n is the full Java SE release and update number (for example, n = 1.8.

Where is JRE path in Windows?

JRE_HOME. C:\Program Files\Java\jre<version>


2 Answers

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment
like image 76
finnw Avatar answered Oct 18 '22 19:10

finnw


Windows > Start > cmd >

C:> for %i in (java.exe) do @echo.   %~$PATH:i

If you have a JRE installed, the Path is displayed, for example: C:\Windows\System32\java.exe

like image 24
grokster Avatar answered Oct 18 '22 18:10

grokster