File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Modify a property file which is a resource in a jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Modify a property file which is a resource in a jar file" Watch "Modify a property file which is a resource in a jar file" New topic
Author

Modify a property file which is a resource in a jar file

andy kumar
Ranch Hand

Joined: Jun 08, 2009
Posts: 44
Hi All,

I have a property file as a resource in my jar file which I am loading using a class loader. I am then using these properties in my application as and when required. I wanted to know if it is possible to modify the contents of the resource property file from a java program or not.

Thanks in advance.

Thanks
Andy
James Dixon
Ranch Hand

Joined: Jun 20, 2009
Posts: 32
Hi Andy
I guess in answer to your question it depends...
If you have signed the Jar file then any updates to it will invalidate the signature. But if the Jar file isn't then I guess it would be possible as it is just a zip file, meaning that you can add and remove files to and from the zip file, but this really isn't ideal as there is the possibility that your application may become corrupted.

A better way (and probably less hassle) would be to just save these settings to a user config file the first time the user opens the app, and then read/write to that whenever they make any changes. At least then if this file becomes corrupted they only have to delete that one file rather than re-installing the whole app...

andy kumar
Ranch Hand

Joined: Jun 08, 2009
Posts: 44
HI James,

Thanks for your answer and sorry for the delay in reply.
My jar file is not signed, well to be more precise it is actually a war file deployed on tomcat and I don't think I can modify the resource which is a property file without redeploying the application. SO I am now using a regular properties file and NOT a property file as a resource.

Thanks for your help.

Thanks
Andy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modify a property file which is a resource in a jar file
 
Similar Threads
How to modify .cmd file
Including / accessing .txt files inside .jar file
Modifying existing jar file, how?
Use external properties in the Jar file
TEMP file question