The Problem
When executing Java code that interacts with the Windows registry - particularly when using the FindBugs Maven plugin or running IntelliJ IDEA - you may encounter the following warning:
1
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Error code 5 means “Access Denied.” The Java Preferences API attempts to store system-level preferences in the Windows registry but lacks the necessary permissions to create the required registry keys.
Solution
Create the missing registry keys with appropriate permissions:
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\PrefsHKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\JavaSoft\Prefs
Step-by-Step Fix
-
Open the Registry Editor by pressing
Win + R, typingregedit, and pressing Enter. -
Navigate to
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node. -
Right-click on
WOW6432Node, select New then Key, and name it JavaSoft. -
Inside the new
JavaSoftkey, create another key named Prefs. -
Repeat steps 2 through 4 for the
HKEY_LOCAL_MACHINE\SOFTWAREpath (without theWOW6432Nodeportion).
After creating both keys, the warning will no longer appear when running Java applications.