抑制 Java 首选项 Systemroot 警告

Suppressing Java Preferences Systemroot Warning

如何通过以下代码抑制打印到控制台的警告:

Preferences systemRoot = Preferences.systemRoot();

警告如下(或类似):

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

注:
我只想通过不向控制台打印任何内容和 not manually create a registry key or running the application as administrator.

来忽略此警告

这里是负责警告的方法:

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;
            return;
        }
        // Check if a new node
        newNode = (result[DISPOSITION] == REG_CREATED_NEW_KEY);
        closeKey(result[NATIVE_HANDLE]);
    }

我明白了:)

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

或者this