Hi ! I found an instruction in my assignment, URLyBird, to make the application configuration persistent among its executions. Probably to save the user preferences. I did it using the java.util.Properties stored in a file on the user home directory, I mean by "user home directory" the . What about it ? Is it a good approuch ? Would I have any problem running this in any OS's ? Thank you very much ! Michel.
Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
By "current working directory" I understand that it's the directory where the "runme.jar" is. So, you don't need to get the user directory from the system. Just give a FileOutputStream("suncertify.properties") to the store method, and it'll be stored in the current working directory. Regards, Flavio.
Hello ! It was my first approuch, but since I was unable to load the configuration when running the application from any directory, not the working directory, I could not get the suncertify.properties file. In the assignment I have instructions to start the application using "java -jar <path>/runme.jar <argument>". In this way, I intent that the user can start the application from any location. So, how to get the absolute path to "suncertify.properties" starting the application out of the working directory ? Can anyone give me another tip ? As I told you before, I did not find any solution. Thanks again ! Michel.
Hi Michel, Instead of using System.getProperty("user.home"), you should use System.getProperty("user.dir"). If you look at the javadoc for System.getProperties(), you'll see that "user.dir" is what SUN means by "current working directory". Regards, Phil.