> Is there a java utility available which uses the compress algorithm?
> compress is a tool available on all the platforms (as far as I can
> tell).
No.
The best bet for cross-platform compression/decompression (especially if you
want to compress more than one file into an archive) is ZIP format (which is
almost the same as JAR format).
A bit of background. There are many compression /algorithms/ and there are
many compression /programs/, but the two are not the same. Any given
compression program will use one or more specific algorithms to compress the
data, and then will write the data out into a specific file /format/. So to
read the file you have to use a program (not necessarily the same program) that
understands that format.
As far as I know, the only compression /algorithm/ that is in widespread use
(i.e. you can expect to find tools that use it on almost any default
installation of almost any OS) is the so-called gzip algorithm. That
algorithm is used in at least two compression /formats/, the format used by the
UNIX-based tool gzip, and the format used by the DOS/Windows/etc-based tool(s)
PKZIP (and other members of that family). Despite the similarity of their
names, those two tools use completely different file formats -- not least
because ZIP is a multiple-file archive format, whereas gzip is (in normal use)
a single-file format.
There are many, many, programs on Windows that understand the ZIP format.
Windows itself does in recent versions. You cannot assume that a Windows
installation will have any tools that understand the gzip format (or the
combination of gzip and tar which is often used). Many Windows installations
/do/ have such tools, but none come as standard, and no single third-party tool
is so dominant that you can assume that users will have installed it, or are
willing to do so.
All UNIX-style boxed understand the gzip format, and they all understand the
tar format too. There is a freely-distributable tool for handling ZIP files
called "zip" (http://www.info-zip.org/), that tool is installed on many
UNIX-like systems by default, but I don't know whether its included in /all/ of
them (I can't think of any reason why it should not be included).
Java has a (somewhat weak) implementation of ZIP file handling and it
understands the gzip format too, but it does not have standard libraries for
handling "tar" files, so it does not (by default) understand the common UNIX
"tarball" (tar + gzip) format.
(The "compress" program, and the corresponding format, is essentially defunct.
You will find it hard to find any tools for non-UNIX OSes that understand it,
and you certainly cannot assume that any particular Windows installation will
have one installed.)
So, you are limited to ZIP and gzip compression if you want to do it in Java.
Neither ZIP nor gzip is so universal that any given installation of any given
OS is /certain/ to have tools for handling it. Of the two ZIP comes closest,
and I would say that it's a rare Windows or UNIX-style installation that
doesn't understand ZIP.
-- chris
ctippur@gmail.com - 02 Dec 2005 11:45 GMT
Chris,
Thanks for the excellent explanation. We have 3 hpux boxes that do not
have zip utility but they do have man pages for the same. I am not sure
what to make out of that but again, thanks for putting everything in
perspective.
- Shekar
>Is there a java utility available which uses the compress algorithm?
>compress is a tool available on all the platforms (as far as I can
>tell).
have a look into pack2000
http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/pack200.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.