简体   繁体   中英

How can I prompt users to grant read/write permission to my program

I've made a lovely computer program in Java, equipped with handy jpackage installers, and I would love to share it with all of the world in a user-friendly manner. As part of its design, my program writes the user's custom settings to a file in the installation directory using an ObjectOutputStream . Unfortunately the program lacks permission to read and write files in secure folders such as "Program Files".

I can't expect average users to know how to set up a policy file, so is there some way I can automate this process or prompt the user to grant read/write permissions during installation without paying hundreds of dollars to a Code Certifying Authority? Or should I continue what I'm already doing which is asking users to install the software to their home directory or run the program as administrator? What do other programmers do in this type of situation?

You can use local application data directory for these kind of files. See What is the cross-platform way of obtaining the path to the local application data directory? for details

You shouldn't write to files to save user settings.

Java have a much better way of saving settings with Preferences: https://docs.oracle.com/javase/8/docs/api/java/util/prefs/Preferences.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM