Is there a system-wide version of the Preferences

2019-06-28 01:44发布

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

2条回答
走好不送
2楼-- · 2019-06-28 02:19

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

查看更多
淡お忘
3楼-- · 2019-06-28 02:26

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

Preferences.systemRoot();
Preferences.userRoot();
查看更多
登录 后发表回答