Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Replace the content of a file in a jar file dynamically.

807606Mar 2 2007 — edited Mar 2 2007
Hello, everybody! I need your help.
In my application jar file I have a META-INF directory and inside this directory I have a file named persistence.xml. So, the persistence.xml is statically placed in my jar file; I cannot change it anymore once the jar is generated.
But I don't want this. I want to be able to load this file dynamically at runtime. I mean, in the user computer I want to create a file named persistence.xml, place it in the same directory where the jar file is and the application load this file with its content and replace the file that is inside the jar file. So, once loaded, my application will see the file that was loaded, not the file with the old content that is inside that jar file.
Maybe I have to use getResource or getResourceAsStream, but I don't know how to make these methods replace the file that is in the jar file.

Thank you in advance.

Marcos
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2007
Added on Mar 2 2007
15 comments
2,232 views