gpt4 book ai didi

java - 抑制 Java 首选项系统根警告

转载 作者:行者123 更新时间:2023-11-30 08:34:00 25 4
gpt4 key购买 nike

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

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 keyrunning 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 .

关于java - 抑制 Java 首选项系统根警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39120693/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com