问题描述
在上一个问题中,我了解了首选项API。不幸的是,这似乎只是用户特定的首选项。我还具有需要能够跨用户设置的首选项。在Java中使用平台无关的方法是什么?
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?
编辑:
但是下面有很好的信息自实施以来,我遇到了障碍...首先在我的开发盒上进行了测试(Win 7,关闭了UAC),它运行良好。在我的第一个测试VM上对其进行了尝试,但失败了...在启用UAC的Win 7上,写入失败(我可以先进行写入操作,然后进行读取操作,而不能得到刚放入的值)。
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).
推荐答案
和方法为您提供所需的内容。
The systemNodeForPackage()
and systemRoot
methods of the Preferences
class give you just what you want.
这篇关于是否存在系统范围的Preferences API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!