Is there a system-wide version of the Preferences API?

别来无恙 提交于 2019-12-23 13:56:08

问题


In a previous question, I learned about the preferences API. Unfortunately, it only appears to be user-specific preferences. I also have preferences that need to be able to be set across users. What is the platform-independent way to do that in Java?

EDIT:

Good info below, however since implementing I ran into a snag... Tested first on my dev box (Win 7, UAC off) and it works fine. Tried it on the first of my test VMs and it fails... On Win 7 with UAC on, writes fail (I can do a write followed by a read and not get the value I just put in there).


回答1:


The systemNodeForPackage() and systemRoot methods of the Preferences class give you just what you want.




回答2:


Preferences has both user and system prefs, read the docs carefully.

Preferences.systemRoot();
Preferences.userRoot();


来源:https://stackoverflow.com/questions/4625992/is-there-a-system-wide-version-of-the-preferences-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!