'jar' better than 'zip' ?

I recently learned that 'jar' can write to stdout. I think this tends to be overlooked for 3 reasons.

  1. 'jar' command line help doesn't suggest so unlike 'tar'.
  2. 'man jar' not possible on many installations.
  3. '-' doesn't mean stdout for 'jar' command.

Where 'man jar' runs, it shows below:

jar-The Java Archive Tool

To copy directories, first compress files in dir1
to stdout, then extract from stdin to dir2 (omitting the
-f option from both jar commands):

% (cd dir1; jar c .) | (cd dir2; jar x)

Firstly, I think this command will add MANIFEST to destination. One can do:

$ (cd dir1; jar cM .) | (cd dir2; jar x)

Secondly, I think better example would be over the network transfer.
This is what I do on Windows with PuTTy command line tool.
I can do same with 'tar.gz' but when I want to send this to someone, *.zip is handier.

$ plink myid@myserver 'cd data/ && jar cM *.txt *.csv' > allData.zip

So, although 'jar' and 'zip' creates archive in same format, jar is better for 2 reasons.

  1. 'zip' doesn't take directory name as argument
  2. No support for stdout. 'man zip' says there is some support but that's not for 'file system' archive.
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today