Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As the accepted answer already pointed out, you can't use neither the <code>zip</code> nor the <code>jar</code> command to insert a <strong>specific file</strong> on the file system to a specific directory inside the compressed file.</p> <p>But there is this <strong>workaround</strong>, which in a nutshell extracts a specific file inside the compressed file first, you can update it and then put it back into the compressed file:</p> <p><strong>1. Extracting a single file :</strong> <br/> Consider a jar with the following contents </p> <pre><code>$ jar tvf foo.jar 0 Thu Jan 10 00:05:06 IST 2013 META-INF/ 68 Thu Jan 10 00:05:06 IST 2013 META-INF/MANIFEST.MF 0 Thu Jan 10 00:04:30 IST 2013 x/ 0 Thu Jan 10 00:07:36 IST 2013 x/b/ 9 Thu Jan 10 00:07:36 IST 2013 x/b/hello.txt 0 Thu Jan 10 00:04:30 IST 2013 x/a/ </code></pre> <p>To extract only hello.txt, you have to give fully qualified path of the file-to-extract. Jar creates appropriate folders too.</p> <p><em>Example :</em> </p> <pre><code>$ jar xvf foo.jar x/b/hello.txt inflated: x/b/hello.txt $ tree x/ x └── b └── hello.txt 1 directory, 1 file </code></pre> <p><strong>2. Updating a Single File</strong></p> <ol> <li>Modify the extracted file</li> <li>update the jar using the 'u' flag. Provide the exploded directory root and jar shall update all the path elements under it.</li> </ol> <p><em>Example:</em></p> <pre><code>$ jar vfu foo.jar x/ adding: x/(in = 0) (out= 0)(stored 0%) adding: x/b/(in = 0) (out= 0)(stored 0%) adding: x/b/hello.txt(in = 23) (out= 11)(deflated 52%) </code></pre> <p><strong>3. Which version of jar I tried this out with ?</strong></p> <p>I used <code>jar</code> bundled with JDK 7 on Fedora 17.</p> <hr/> <p>I have verified all the steps mentioned here. Hope this helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload