Trying to use Preferences in java but need admin rights (need to work on windows and MAC)

StackOverflow https://stackoverflow.com/questions/21486464

سؤال

I am trying to save some settings for my program.

I am for instance asking the user to pick a folder when the program is run for the first time.

this is all working and wonderfull, but it does not get saved.

prefs = Preferences.userRoot().node(this.getClass().getName());

Returns with WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

error code 5 (access denied)

How do i ask for admin rights? both on windows and mac, thank you for your time!

هل كانت مفيدة؟

المحلول

I actually found out when using userRoot(), that the program indeed makes the key. It just throws a warning because java tries to make it in systemRoot() aswell, just incase you ever need it in systemroot. When you are using userRoot() you never will.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top