Alosyius
Alosyius

Reputation: 9121

Java store config and other files

Currently i am storing a few config files and a history.xml file right next to my executable .exe.

However some users have reported that they have to run my program with Administrator rights, otherwise settings and history is not saved to these files.

Where should i save my config files and history.xml in order to not require my users to run the app with administrator rights?

Would be really nice with a solution that works on both Windows and OSX

Any ideas?

Upvotes: 0

Views: 92

Answers (1)

testuser
testuser

Reputation: 982

Your users are probably saving the files in a folder under Program Files or another 'protected' folder.

Either they should save it in a users-folder, or you should work with a full path to some path on the system, like 'C:/myapp/'.

You can use a helper function to check if you're using Windows or *Nix, and then depending on that return a certain path. I'm not close to my computer so can't test but this should work:

return System.getProperty("os.name").egualsIgnoreCase("Windows");

You can also make use of "user.home" for the users home directory (always writeable) and "file.separator" so you don't even need to check whether you're on Windows or not.

Upvotes: 2

Related Questions