What do I need exactly is to store information like applications first execution date and few settings somewhere on the user machine. The program will be distributed on Windows and Mac OS. This information needs to be shared between the users on same machine... somewhat global settings. On windows I'd probably store this information in registry, not sure about Macs... I'd really like a multiplatform solution for this, otherwise please advise platform specific ones.
+6
A:
use java.util.prefs.Preferences
If you want all users on the machine to use the same properties, use Preferences.systemRoot()
(rather than Preferences.userRoot()
)
Bozho
2010-10-12 09:13:55
will it work for multiple users on mac?
tulskiy
2010-10-12 12:03:53
see my update..
Bozho
2010-10-12 12:04:41
Thanks for the answer and this really would solve all my problems if it worked :D 2 problems with using Preferences: 1) on windows certain registry keys have to be already created in order for this to work, or you have to be administrator, otherwise you get lots of warnings and nothing gets saved. Make the installer create this keys? maybe... lots of pain... 2) on mac systemRoot will persist on hard drive only if the user running the program is administrator/root. Bottom line it seems I cannot use this solution for our product since it targets average user :/
m0s
2010-10-13 07:54:58
well, if you want to store system-wide properties, I guess being admin is logical. Otherwise you should be able to use `userRoot()` (per-user).
Bozho
2010-10-13 08:17:48
+2
A:
Try the Preferences
class. It can store user or system preferences. Sounds like you need to use system preferences as they are the same for all users.
The implementation is system specific, for Windows it will use the registry. Not sure about Mac.
Qwerky
2010-10-12 09:16:06
+2
A:
If @bozho excellent proposal does not fullfils your requirements, you can also go the Apache way, by using commons configuration.
Riduidel
2010-10-12 09:16:25
Well, in that case, @willcodejavaforfood +1 for your excellent pseudo :-)
Riduidel
2010-10-12 12:46:54