Forum Stats

  • 3,837,916 Users
  • 2,262,307 Discussions
  • 7,900,431 Comments

Discussions

My Application became Readonly, Installed in windows 7's C:\Program Files\

923153
923153 Member Posts: 10
edited Apr 4, 2012 11:48PM in Java Desktop Applications
Hi guys I have created some programs for just learning purpose using Swing, SWT and JavaFx 2.0. I created a installer for them. They work fine after installation except when they are installed in C:\Program files\ in windows7. It become readonly and does not edit the supporting files and even the Sqlite3 database.

Well I know the root of the problem. It is the UAC permission system that requires the Application to run in elevated permission mode to edit any file in C:\Program Files\ folder.

but how to solve it??

Answers

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    Don't install in a protected folder if files need to be modified.

    A better solution is to make a clear separation between read only files and writable files. Read only files can go anywhere, as long as files that need to be writable go in the user's home folder where you are guaranteed that the logged in user can write. If you want to be 100% robust you'd give the user the choice of where to put files of course.
  • 923153
    923153 Member Posts: 10
    Thanks for the reply.

    I agree with your solution but then again the solution raises a concern that if I prompt the user to save the files to where he want then I have to store the location of the files in another file which in turn is to be saved in some writable location.....
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    Not necessarily, you could use the java preferences API to store the location for files.

    http://docs.oracle.com/javase/1.4.2/docs/guide/lang/preferences.html

    It is OS specific where this information is stored; under Windows it will go into the registry for example.
    gimbal2
  • 923153
    923153 Member Posts: 10
    Thanks a lot....
    Preference API looks helpful
This discussion has been closed.