Programming Tutorials

Update contents of a file within a jar file

By: Naren in Java Tutorials on 2015-04-24  

Recently there was a change of IPs in my servers. Therefore some of the applications stopped working. For example, there was an application that was running as an executable jar file. The access to other resources from that application was using IP Addresses and there was a config file named bcconfig.xml that had all the IP addresses of various resources the application needs to access.

This bcconfig.xml was bundled within the jar file and as this was a legacy application we did not want to recompile the source files and regenerate the entire jar file. So what we did is to just make changes to bcconfig.xml and repackage it to the same jar file. If you are facing with similar issue, then there is a simple method to just update the bcconfig.xml file and update the jar file. Once your bcconfig.xml file is ready with the new IP addresses, just run the below command to update the jar

#jar uf mlsscheduler.jar bcconfig.xml

The other way to do is to just use applications such as WinRAR to open the jar file and then drag and drop the files in it. :). It really works.






Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)