BullyWiiPlaza BullyWiiPlaza - 8 months ago 58
Java Question

Suppressing Java Preferences Systemroot Warning

How do I suppress the warning printed to the console by the following piece of code:

Preferences systemRoot = Preferences.systemRoot();

The warning is as follows (or similar):

WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.


I want to just ignore this warning by not printing anything to the console instead and not manually create a registry key or running the application as administrator.

Here is the method responsible for the warning:

private WindowsPreferences(int rootNativeHandle, byte[] rootDirectory) {
super(null, "");
int[] result =
WindowsRegCreateKeyEx1(rootNativeHandle, rootDirectory);
if (result[ERROR_CODE] != ERROR_SUCCESS) {
logger().warning("Could not open/create prefs root node " +
byteArrayToString(windowsAbsolutePath()) +
" at root 0x" + Integer.toHexString(rootNativeHandle()) +
". Windows RegCreateKeyEx(...) returned error code " +
result[ERROR_CODE] + ".");
isBackingStoreAvailable = false;
// Check if a new node


I got it :)

PlatformLogger platformLogger = PlatformLogger.getLogger("java.util.prefs");

Alternatively this.