To get only 64 bit JRE value from Windows Registry

As i am from testing background and have a very limited knowledge on Java kindly excuse me if the question i have asked is not good or repetative.

I am trying to build an application using Java Swing. As per the requirement i have to display 32 bit Jre or 64 bit Jre installed on laptop based on the selection made. Frame which i developed for this

Unfortunately when i tested by installing a 32 bit JRE on Windows 64 bit machine and tried to run my application, when i choose the radio button “64 bit JRE” , in the drop down list its displaying me the 32 bit JRE which is installed on my system. (Kindly note i do not have any 64 bit JRE installed on my system). Ideally it should not display anything but the default value set in the JComboBox. 🙁

I understood the JRE was picked due to the Windows property. I tried with the API Advapi32.INSTANCE using the method RegGetValue but i am unable to get the value from Windows Registry.

32 bit JRE are under the path : HKEY_LOCAL_MACHINESOFTWAREWOW6432Node JavaSoftJava Runtime Environment
and 64 bit JRE are under the path : HKEY_LOCAL_MACHINESOFTWAREJavaSoftJava Runtime Environment

Please find the below code which i tried to retrieve 64 bit JRE :

String[] val64 = RegistryCheck.getRegistryDataForJRE(HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Runtime Environment"); 

public static String[] getRegistryDataForJRE(WinReg.HKEY root, String key) {

if (Advapi32Util.registryKeyExists(root, key)) {
    return Advapi32Util.registryGetKeys(root, key);
} else {
    return null;


Also below is the code which i tried with Advapi32.INSTANCE (just ttried to do a sysout to know whether the value returned is 0 or not. as from the Microsoft pages i see if its a non zero value returned its an error

public static void main(String[] args) {

byte[] b = new byte[50];
IntByReference pcbData = new IntByReference(50);

System.out.println(Advapi32.INSTANCE.RegGetValue(HKEY_LOCAL_MACHINE, "SOFTWARE\JavaSoft\Java Runtime Environment",
        "" , 0x0200, pcbData, b, pcbData));


Also, i read the flag KEY_WOW64_32KEY is the responsible to pick up from the WOW6432Node , but i am not able to check the flag value or to set it to false in java.

Can anyone help me with this issue ?

I would be really grateful for the help.

Thank you in advance for the support.