I’m trying to detect if there is a JVM installed and where it is located so I can run java.exe.
All I’ve managed to find is HKCU\Software\JavaSoft\Java Runtime Environment\<ver>. Is it safe to assume that it is installed in %PROGRAMFILES%\Java\jre<ver>?
I’m trying to do this in C#, but I assume the answer is pretty language agnostic, so any answer is appreciated.
EDIT: Ok silly me, I found How to detect whether java runtime is installed or not on a computer using c# which pointed me at HKLM\Software\JavaSoft\Java Runtime Environment\CurrentVersion which works with HKLM\Software\JavaSoft\Java Runtime Environment\<ver>\JavaHome. I managed to find these instead underneath HKLM\Software\Wow6432Node\JavaSoft\Java Runtime Environment. Is there some way to detect which of these I should be checking without trying to sniff at the CPU type?
I’m going to throw my hat in the ring with the code I’ve ended up using: