Is there a way to modify the property values in a Properties file that is stored in a Jar file as a Resource?
This is the scenario that I am trying to handle. I have a properties file stored as a resource in my Jar file. There are some system specific properties, for example, paths. I want to be able to change this for the system that I want the Jar file to run on.
The best solution would be to call a class/method that is internal to the Jar file that will modify the resource file that is contained in the Jar. Another solution would be to run a utility program on the Jar file that will modify the property file and re-Jar everything. This will be a one-time setup process that I run on the Jar file.
解决方案
Edit after re-reading the question: are you in a situation where you want to send out the JAR to potentially many people and have it customized on install? If yes, then prefs is the way to go.
If, instead, you're looking to customize for a relatively small number of deployments, then it's probably better to do the customization at build-time.