0

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?

Christabear
  • 33
  • 1
  • 5
  • Do you mean something like this? [Elevate java application while running](https://stackoverflow.com/questions/30082838/elevate-java-application-while-running) – Lino Jun 23 '20 at 13:21
  • @Lino It seems like overkill to grant full administrator privileges when all you need is read/write access to one or two files, but it would be nicer than making my users remember an extra step. – Christabear Jun 23 '20 at 13:44

2 Answers2

1

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

hkn
  • 1,453
  • 19
  • 21
1

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

Saeid Nourian
  • 1,606
  • 15
  • 32