I have a swing application which contains a property file. When the application start, it will read this file and get some info. Now this file is in the root directory within a jar file. And it works fine.
The problem is that when the jar file is given to a user, that user may want to change some info of the property file. It is not good to ask user to unzip the jar, change the file, and jar the files together, right?
Could I put the property file outside the jar file, and give it to user together with the jar file, then user can edit it conveniently, but how the application find this file in this case?
What is the professional way to deal with this problem?
What if your code allows for 2 property files. The one in the jar file would be the default if there isn't one in the folder with the jar file. Your program would write out a copy of the jar file on its first execution. Later it would test if there was a file in the folder and use it vs using the one in the jar.
How about putting a copy in System.getProperty("user.home")? That's what most applications do. (Although on Windows, using the ApplicationData (Windows 2000 and XP) / AppData\Local (Windows Vista and 7) is a better location.) You can then first create a Properties object around the file in the JAR file, then use that as the parent for a Properties object around this user specific properties file.