posted 16 years ago
When you run your application, do you have any idea if it has ever been run from another directory?
What I do is the next. I have a default definition on my suncertify.properties file stored in the runme.jar file. When I run the application I check if the file exists in the current working directory (System.getProperty("user.dir").
If the file is not in the current directory then I copy it from the the runme.jar and store the copy in the working directory. Then I display a dialog box for the user to check the current settings.
If the user is going to launch the application from another directory he would be responsible for moving the suncertify.properties settings to the new working directory.
Sadly, the instructions.html file states that the suncertify.properties file should be stored in the working directory.
Otherwise I could have saved the file in the user's home directory in hidden application settings folder like /home/edalorzo/.urlybird or somewhat like that. This way it would not matter where the user moves the working directory, I would always load the settings from his home folder.
If you want to keep the settings even when you move the working directory, then you will have to store them in both places, the working directory and in the user's home directory.
The first time the application is run you must create the application settings directory as a hidden file in the home folder.
Then make a copy of the file in the current working directory and run the application from there, using that file.
If the user changes the settings, you change them in both places.
If the user changes the working directory, then you check in the application settings directory exists in the home folder and make a copy of the file in the current working directory. This way, you would be keeping the settings no matter if the user change the current working directory.
This strategy, notwithstanding, is more than what the specification requires.
[ October 02, 2006: Message edited by: Edwin Dalorzo ]