writing files as user, privileges

been using windows 7 lately
now I realize that saving savegames and screenshots to a subfolder of my game, which (when deployed) has been installed obviously to c:\program files\game or similar in windows, doesnt really work, because a user shall not save files to C:

can a Java app ask for admin right at start ?

other than that you would just make a folder in the home folder of the user and use that to save any files, right ? - and that works every time ?

You can use FileSystemView.getFileSystemView().getDefaultDirectory() to get the home/profile directory on different platforms. Doesn’t always work from an Applet, though.

System.getProperty(“user.home”); should get the user’s home directory. As for the permissions I have no idea, but I’d like to know.

yea I would create a folder in that directory
question is, is it guaranteed to work ?

In terms of permissions, you can get access the client’s computer via JNLP. I’ve done it before with an app that loads and plays .wav files from a client. However, the system steps in and ask the client to give permission. I used the code presented in this tutorial as my model.
http://download.oracle.com/javase/tutorial/deployment/doingMoreWithRIA/usingJNLPAPI.html

But if you want freer access, you will have to look at “Signing”.
http://download.oracle.com/javase/tutorial/deployment/jar/signindex.html

Lot’s to get confused by in that. I remember having troubles with the Keystore (for Signing) but found some useful background in this article:
http://download.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html

If you get it all working, I’ll probably be back to ask you for advice. I got side-tracked when I was trying to set this up signing and never finished it. :slight_smile: (I have this topic on “notify,” in hopes.)

signing jars… yea not what I would wanna do. Also just java apps, no applets or webstarts, that I am interested in.

if making folder und writing files to the System.getProperty(“user.home”) folder, always succeeds, then it’s fine D=

Yes, it should always work for desktop games (not applets); users should always be able to write to their own home directories, and the “user.home” property is guaranteed to be defined.

No applications of any sort has default write access to “C:\Program Files”. You have to have the UAC prompt that allows the program to run with Administrator access.