Using reg [.exe], you can query for possible JRE candidates that are installed on the system. They can not be, or there can be several.
In a test setup running inside a command shell:
reg query "HKLM\Software\JavaSoft\Java Runtime Environment"
I get three rows of results, the first of which
CurrentVersion REG_SZ 1.6
Based on this, the request
reg query "HKLM\Software\JavaSoft\Java Runtime Environment\1.6\"
JavaHome REG_SZ C:\Program Files\Java\jre6
, , java .
32- Windows XP.