JZlib - zlib in pure Java
JZlib is a re-implementation of
zlib
in pure Java.
The first and final aim of developing JZlib was
to add packet compression support to pure Java SSH systems.
Zlib
zlib is designed to be a free, general-purpose, legally unencumbered -- that is, not covered by any patents -- lossless data-compression library for use on virtually any computer hardware and operating system. zlib was written by Jean-loup Gailly (compression) and Mark Adler (decompression).
Features
- Needless to say, JZlib can inflate data, which is deflated by zlib and JZlib can generate deflated data, which is acceptable and is inflated by zlib.
- JZlib supports all compression levels and all flushing modes in zlib.
- JZlib does not support gzip file handling.
- The performance has not been estimated yet, but it will not be so bad when deflating/inflating data streams on low-bandwidth networks.
- JZlib is licensed under a BSD style license.
- No invention has been made in developing JZlib. So, if zlib is patent free, JZlib is also not covered by any patents.
Why JZlib?
Java Platform API provides packages 'java.util.zip.*' for accessing zlib, but that support is very limited if you need to use the essence of zlib. For example, we needed full access to zlib to add packet compression support to a pure Java SSH system, but it is useless for our requirements. The Internet draft SSH Transport Layer Protocol says in the section '4.2 Compression' as follows,
The following compression methods are currently defined:
none REQUIRED no compression
zlib OPTIONAL GNU ZLIB (LZ77) compression
The "zlib" compression is described in [RFC-1950] and in [RFC-1951]. The compression context is initialized after each key exchange, and is passed from one packet to the next with only a partial flush being performed at the end of each packet. A partial flush means that all data will be output, but the next packet will continue using compression tables from the end of the previous packet.
To implement this functionality,
the Z_PARTIAL_FLUSH mode of zlib must be used,
however JDK does not permit us to do so.
It seems that this problem has been well known and
some people have already
reported to JavaSoft's BugParade(for example,
BugId:4255743),
but no positive response has been returned from JavaSoft,
so this problem will never be solved.
This is our motivation to develop JZlib.
Of course, JZlib should be useful for any other pure Java programs
which need to communicate with compressed data streams.
Feel free to use JZlib in your own projects, and
we would be very happy to get some feedback.
Applications Using JZlib
- JSch uses JZlib for the packet compression.
- JMakeztxt
- Apache MINA
- Netty
- Zimbra
- as3zlib
- Zlib.cs
- IronPython.Zlib
- Nokia Data Gathering
- Oracle Database Lite
References
We have referred to the following works in developing JZlib.
- [RFC-1950] Deutch, P. and Gailly, J-L: "ZLIB Compressed Data Format Specification version 3.3", May 1996.
- [RFC-1951] Deutch, P: "DEFLATE Compressed Data Format Specification version 1.3", May 1996.
- zlib-1.1.3.tgz
- zlib-1.2.1.tgz
Download
JZlib 1.1.3 is provided in the zip format,
and also its latest source code is available at
Maven Repository
- JZlib has been available at the central Maven repository.
- Jar files have been signed with our PGP key, and our public key has been
located on hkp://pgp.mit.edu. You can get it with
$ gpg --keyserver hkp://pgp.mit.edu --recv-keys CA7FA1F0
Presentations
- JZlib and an aged fixed bug in Java7 presented at Java SE 7 Launch Event in Sendai(2011/09/04) in Japanese
Credits
JZlib has been developed by ymnk, but he has just re-implemented zlib in pure Java(it was just required to improve the service on WiredX.net). So, all credit should go to authors Jean-loup Gailly and Mark Adler and contributors of zlib.
Comments/suggestions are accepted at jzlib@jcraft.com.
``SSH is a registered trademark and Secure Shell is a trademark of SSH Communications Security Corp (www.ssh.com)''.