<p>I currently am tasked with updating an XML file (persistance.xml) within a jar at a customers site.  I can of course unjar the file, update the xml, then rejar the file for redeployment.  I would like to kind these command line operations in a Swing App so that the person doing it does not have to drop to the command line.  Any thoughts on a way to do this programatically?  </p>

[{'answer_id': 74684, 'author': 'Dan Dyer', 'author_id': 5171, 'author_profile': 'https://Stackoverflow.com/users/5171', 'pm_score': 4, 'selected': True, 'text': '<p>The Java API has <a href="http://java.sun.com/javase/6/docs/api/java/util/jar/package-summary.html" rel="noreferrer">classes</a> for manipulating JAR files.</p>\n'}, {'answer_id': 74688, 'author': 'Bill the Lizard', 'author_id': 1288, 'author_profile': 'https://Stackoverflow.com/users/1288', 'pm_score': 1, 'selected': False, 'text': '<p>You can use Java\'s <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipFile.html" rel="nofollow noreferrer">ZipFile</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipEntry.html" rel="nofollow noreferrer">ZipEntry</a> classes to read the contents of a JAR file, then use <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipOutputStream.html" rel="nofollow noreferrer">ZipOutputStream</a> to create a new one.</p>\n'}, {'answer_id': 74702, 'author': 'jodonnell', 'author_id': 4223, 'author_profile': 'https://Stackoverflow.com/users/4223', 'pm_score': 2, 'selected': False, 'text': '<p>Sure:</p>\n\n<pre><code>File tmp = new File ("tmp");\ntmp.mkdirs();\nProcess unjar = new ProcessBuilder ("jar", "-xf", "myjar.jar", tmp.getName ()).start();\nunjar.waitFor();\n// TODO read and update persistence.xml\nProcess jar = new ProcessBuilder ("jar", "-cf", "myjar.jar", tmp.getName()).start();\njar.waitFor();\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/74641', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/387361/']