java 首选项 API 存储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1320709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Preference API storage
提问by rupa
If I use the Preference APIto store user or system preferences, where are they stored on Windows and Unix?
如果我使用Preference API来存储用户或系统首选项,它们在 Windows 和 Unix 上存储在哪里?
回答by n002213f
For Windows systemRoot and userRoot are stored in HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefsand HKEY_CURRENT_USER\Software\JavaSoft\Prefsrespectively.
对于 Windows,systemRoot 和 userRoot 分别存储在HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Prefs和HKEY_CURRENT_USER\Software\JavaSoft\Prefs 中。
For Unix systemRoot and userRoot are stored in "/etc/.java"and "${user.home}/.java/.userPrefs", respectively.
对于 Unix,systemRoot 和 userRoot 分别存储在"/etc/.java"和"${user.home}/.java/.userPrefs" 中。
Note that for Unix the locations can be changed by specifying "java.util.prefs.userRoot"and "java.util.prefs.systemRoot"properties
请注意,对于 Unix,可以通过指定“java.util.prefs.userRoot”和“java.util.prefs.systemRoot”属性来更改位置
回答by MyPasswordIsLasercats
I have to extend n002213fs' answer, because it seems to me, that the Storage Location is a big mess. Note that Windows saves it in the Windows Registryand Unix saves it in prefs.xml-files.
我必须扩展 n002213fs 的回答,因为在我看来,存储位置是一团糟。请注意,Windows 将其保存在Windows 注册表中,而 Unix 将其保存在prefs.xml-files 中。
userRoot
用户根
- Windows (32Bit):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs - Windows (64Bit) with JVM (64Bit):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs - Windows (64Bit) with JVM (32Bit):
HKEY_CURRENT_USER\Software\Wow6432Node\JavaSoft\Prefs - Unix:
System.getProperty("java.util.prefs.userRoot")or(if the previous value is not set)~/.java/.userPrefs
- 视窗(32位):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs - 带有 JVM(64 位)的 Windows(64 位):
HKEY_CURRENT_USER\Software\JavaSoft\Prefs - 带有 JVM(32 位)的 Windows(64 位):
HKEY_CURRENT_USER\Software\Wow6432Node\JavaSoft\Prefs - Unix:
System.getProperty("java.util.prefs.userRoot")或(如果未设置前一个值)~/.java/.userPrefs
systemRoot
系统根
- Windows (32Bit):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs - Windows (64Bit) with JVM (64Bit):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs - Windows (64Bit) with JVM (32Bit):
HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Prefs - Unix:
System.getProperty("java.util.prefs.systemRoot")or(if the previous value is not set)System.getProperty("java.home")+"/.systemPrefs"(System.getProperty("java.home")might be/etc/.java/. You can check it in a terminal with$JAVA_HOME.)
- 视窗(32位):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs - 带有 JVM(64 位)的 Windows(64 位):
HKEY_LOCAL_MACHINE\Software\JavaSoft\Prefs - 带有 JVM(32 位)的 Windows(64 位):
HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Prefs - Unix:
System.getProperty("java.util.prefs.systemRoot")或(如果未设置前一个值)System.getProperty("java.home")+"/.systemPrefs"(System.getProperty("java.home")可能是/etc/.java/。您可以在终端中使用$JAVA_HOME.)

