{"id":368,"date":"2007-10-21T00:00:00","date_gmt":"2007-10-21T00:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=368"},"modified":"2007-10-21T00:00:00","modified_gmt":"2007-10-21T00:00:00","slug":"Updating a JAR File","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=368","title":{"rendered":"Updating a JAR File"},"content":{"rendered":"<p><DIV id=PageTitle>Updating a JAR File<\/DIV><br \/>\n<BLOCKQUOTE>The Jar tool provides a <TT>u<\/TT> option which you can use to update the contents of an existing JAR file by modifying its manifest or by adding files.<br \/>\n<P>The basic command for adding files has this format: <\/P><br \/>\n<BLOCKQUOTE><PRE>jar uf <I>jar-file input-file(s)<\/I><br \/>\n<\/PRE><\/BLOCKQUOTE><br \/>\n<P>In this command: <\/P><br \/>\n<UL><br \/>\n<LI>The <TT>u<\/TT> option indicates that you want to <EM>update<\/EM> an existing JAR file. <\/LI><br \/>\n<LI>The <TT>f<\/TT> option indicates that the JAR file to update is specified on the command line. <\/LI><br \/>\n<LI><TT>jar-file<\/TT> is the existing JAR file that&#8217;s to be updated. <\/LI><br \/>\n<LI><TT>input-file(s)<\/TT> is a space-deliminated list of one or more files that you want to add to the Jar file. <\/LI><\/UL><br \/>\n<P>Any files already in the archive having the same pathname as a file being added will be overwritten. <\/P><br \/>\n<P>When creating a new JAR file, you can optionally use the <TT>-C<\/TT> option to indicate a change of directory. For more information, see the <A class=TutorialLink href=\"http:\/\/www.strongd.net\/blog\/show\/365\" target=_top>Creating a JAR File<\/A> section. <\/P><\/BLOCKQUOTE><br \/>\n<H3>Examples<\/H3><br \/>\n<BLOCKQUOTE>Recall that <TT>TicTacToe.jar<\/TT> has these contents:<br \/>\n<BLOCKQUOTE><PRE>META-INF\/MANIFEST.MF<br \/>\nTicTacToe.class<br \/>\naudio\/<br \/>\naudio\/beep.au<br \/>\naudio\/ding.au<br \/>\naudio\/return.au<br \/>\naudio\/yahoo1.au<br \/>\naudio\/yahoo2.au<br \/>\nimages\/<br \/>\nimages\/cross.gif<br \/>\nimages\/not.gif<br \/>\n<\/PRE><\/BLOCKQUOTE><br \/>\n<P>Suppose that you want to add the file <TT>images\/new.gif<\/TT> to the JAR file. You could accomplish that by issuing this command from the parent directory of the <TT>images<\/TT> directory: <\/P><br \/>\n<BLOCKQUOTE><PRE>jar uf TicTacToe.jar images\/new.gif<br \/>\n<\/PRE><\/BLOCKQUOTE><br \/>\n<P>The revised JAR file would have this table of contents: <\/P><br \/>\n<BLOCKQUOTE><PRE>META-INF\/MANIFEST.MF<br \/>\nTicTacToe.class<br \/>\naudio\/<br \/>\naudio\/beep.au<br \/>\naudio\/ding.au<br \/>\naudio\/return.au<br \/>\naudio\/yahoo1.au<br \/>\naudio\/yahoo2.au<br \/>\nimages\/<br \/>\nimages\/cross.gif<br \/>\nimages\/not.gif<br \/>\nimages\/new.gif<br \/>\n<\/PRE><\/BLOCKQUOTE><br \/>\n<P>You can use the <TT>-C<\/TT> option to &#8220;change directories&#8221; during execution of the command. For example: <\/P><br \/>\n<BLOCKQUOTE><PRE>jar uf TicTacToe.jar -C images new.gif<br \/>\n<\/PRE><\/BLOCKQUOTE>This command would change to the <TT>images<\/TT> directory before adding <TT>new.gif<\/TT> to the JAR file. The <TT>images<\/TT> directory would not be included in the pathname of <TT>new.gif<\/TT> when it&#8217;s added to the archive, resulting in a table of contents that looks like this:<br \/>\n<BLOCKQUOTE><PRE>META-INF\/MANIFEST.MF<br \/>\nTicTacToe.class<br \/>\naudio\/<br \/>\naudio\/beep.au<br \/>\naudio\/ding.au<br \/>\naudio\/return.au<br \/>\naudio\/yahoo1.au<br \/>\naudio\/yahoo2.au<br \/>\nimages\/<br \/>\nimages\/cross.gif<br \/>\nimages\/not.gif<br \/>\nnew.gif<br \/>\n<\/PRE><\/BLOCKQUOTE><\/BLOCKQUOTE><br \/>\n<DIV><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updating a JAR File The Jar tool provides a u option which you can use to update the contents of an existing JAR file by modifying its manifest or by adding files. The basic command for adding files has this format: jar uf jar-file input-file(s) In this command: The u option indicates that you want &hellip; <a href=\"https:\/\/www.strongd.net\/?p=368\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Updating a JAR File<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368"}],"version-history":[{"count":0,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}