java - How to detect presence and location of JVM on Windows? -


i'm trying detect if there jvm installed , located can run java.exe.

all i've managed find hkcu\software\javasoft\java runtime environment\<ver>. safe assume installed in %programfiles%\java\jre<ver>?

i'm trying in c#, assume answer pretty language agnostic, answer appreciated.

edit: ok silly me, found how detect whether java runtime installed or not on computer using c# pointed me @ hklm\software\javasoft\java runtime environment\currentversion works hklm\software\javasoft\java runtime environment\<ver>\javahome. managed find these instead underneath hklm\software\wow6432node\javasoft\java runtime environment. there way detect of these should checking without trying sniff @ cpu type?

i'm going throw hat in ring code i've ended using:

string javadirectory = null;  // native registry key - 32b on 32b or 64b on 64b // fall on 32b java on win64 if available registrykey javakey =     registry.localmachine.opensubkey("software\\javasoft\\java runtime environment") ??     registry.localmachine.opensubkey("software\\wow6432node\\javasoft\\java runtime environment");  if (javakey != null) {     string javaversion = javakey.getvalue("currentversion").tostring();     try     {         javadirectory = javakey.opensubkey(javaversion).getvalue("javahome").tostring();     } catch(nullreferenceexception)     { /* ignore null deref, means can't directory */ } }  if (javadirectory == null) {     // deal lack of java here. } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -