How to solve the problem 'Could not create windows registry node' with Preferences class in Java?

Viewed 31

I'm trying to use the Preferences class to store some information. Here is the code:


package association;

import java.util.prefs.Preferences;

public class Association {

    Preferences prefs=Preferences.systemNodeForPackage(Association.class);

    public static void main(String[] args) {

        Association temp=new Association();
        String s=temp.prefs.get("name","");
    }
    
}

But whenever I run the code it shows that-

Jul 27, 2022 1:41:17 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not create windows registry node Software\JavaSoft\Prefs\association at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Jul 27, 2022 1:41:17 PM java.util.prefs.WindowsPreferences WindowsRegOpenKey1

WARNING: Trying to recreate Windows registry node Software\JavaSoft\Prefs\association at root 0x80000002.
Jul 27, 2022 1:41:17 PM java.util.prefs.WindowsPreferences openKey

WARNING: Could not open windows registry node Software\JavaSoft\Prefs\association at root 0x80000002. Windows RegOpenKey(...) returned error code 2.

I've opened regedit and found that 'Prefs' key exists in

HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\

Then I've created a 'Prefs' key in

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\JavaSoft\

but it doesn't work. How to solve this?

0 Answers
Related