-It is indicated in my assignment "All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory."
In my implementation, if the user change the working directory, suncertify.properties file will be recreated from scratch, all the properties stored in the suncertify.properties file when working in the old directory will be lost. Does this fit with the exam spec?
if not, how can I keep the same suncertify.properties file even when the user changes the working directory?
Is it required that user changes the working directory ( means your root directory of the application)...User can change only the datbase file locatio n..It means GUI should take care for databse file location ( and port and host in network mode) .I don't see any other things to be persisted in suncertify.properties.Does your specs say that user should able to change the working directory ..(think ..you will only give a jar file ..so only thing user is concerned at most db location,host and port..)..Hope it helps..
SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
From my understanding, a working directory is the directory where the program is launched. So for example, if the jar resides in /home/myself/scjd/runme.jar, I can invoke runme.jar from /home/myself/scjd, and that's the working directory. Or I can invoke it from /home, and that makes /home the working directory.
So I think it's possible that user could change the working directory. That leads to the interesting question that Mike raised.
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 ]
I think you all are making big problems about nothing!
I guess we only have to make sure the settings are persistent in the working directory, so the user doesn't need to retype his settings the next time the app is launched again from the SAME (!!!) working directory...
does someone pass the exam withbout carrying about the user working directory? I mean if the user changes the working directory, the suncertify.properties file will be recreated from scratch and the user will have to provide again all the settings via the GUI.