JZIPUpdate

Hosted by SourceForge.net Logo IE7 Enhanced

Documentation

More documentation, especially about download speed throttling is coming soon!

Requirements

You need the following to use JZIPUpdate:

How To Use

JZIPUpdate can be used both as stand-alone application from a command line*, and of course programmatically from your own code.
*The current stand-alone application always creates a UI progress dialog, so it's currently not possible to run in a pure text-based environment like terminals.

Create an Index of Your ZIP/JAR Files

For JZIPUpdate to be able to download just the ZIP entries that have changed, you need to create an index file whenever you deploy a new ZIP/JAR file on your website. The index files are generated by a utility application included with JZIPUpdate and are quite small.

To generate an index file manually (replace the x.y by the actual version you're using) run:


java -cp jzipupdate-x.y.jar de.vxart.zipupdate.Indexer archive.zip

and to index all ZIP and JAR files in a directory:


java -cp jzipupdate-x.y.jar de.vxart.zipupdate.Indexer /some-directory-with-ZIP-files/

This will generate a file named archive.zip.idx in the same directory as the original archive. The index file needs to be in the same directory on your web server as the actual archive.

Programmatically Updating ZIP/JAR Files

Updating a single ZIP file:


import java.util.zip.ZipFile;
import de.vxart.zipupdate.UpdateEngine;
import de.vxart.zipupdate.UpdateLocation;

...

ZipFile archive = new ZipFile(...);
URL url = new URL("http://www.example.com/files/bar.zip");

UpdateEngine engine = new UpdateEngine();
engine.update(archive, new UpdateLocation(url));

Updating multiple ZIP files:


import java.util.zip.ZipFile;
import de.vxart.zipupdate.UpdateEngine;
import de.vxart.zipupdate.UpdateLocation;

...

ZipFile[] archives = ...;
UpdateLocation[] locations = ...;
String[] messages = ...; // file names do well as detail messages

UpdateEngine engine = new UpdateEngine();
engine.update(archives, locations, messages);

Manually Updating ZIP/JAR Files from the Command Line

Updating a single archive (replace the x.y by the actual version you're using):


java -cp jzipupdate-x.y.jar de.vxart.zipupdate.UpdateEngine archive.zip http://www.example.com/files/bar.zip

or for multiple archives:


java -cp jzipupdate-x.y.jar de.vxart.zipupdate.UpdateEngine /some-directory-with-ZIP-files/ http://www.example.com/files/

Note that when updating multiple files from the command line, you specify a directory containing archives rather than a list of archives, and you provide a "base URL" to which the name of any archive found in the directory will be appended.
For example, when the directory contains monkey.zip and banana.jar, JZIPUpdate will update from http://www.example.com/files/monkey.zip and http://www.example.com/files/banana.jar respectively.

Using the ProgressListener Interface

You probably want to notify your users of the status and progress of running updates, and that's easy to do with the ProgressListener interface.

You can choose between two standard progress dialogs based on Swing or implement the ProgressListener interface yourself.
For updating a single archive, de.vxart.zipupdate.ui.ProgressDialog conveniently displays a dialog with a progress bar, download speed, and estimated remaining time for the update process:

Single progress dialog

When updating multiple archives at once, you can use de.vxart.zipupdate.ui.MultiProgressDialog which adds an overall progress bar to the single-update dialog:

Multi-progress dialog

How to register a ProgressListener

Both standard progress dialogs are easily instantiated and registered to an instance of de.vxart.zipupdate.UpdateEngine:


UpdateEngine engine = new UpdateEngine();
engine.addProgressListener(new ProgressDialog());
engine.update(archive, location);

And for a multi-update dialog, you just do:


UpdateEngine engine = new UpdateEngine();
engine.addProgressListener(new MultiProgressDialog());
engine.update(archives, location, messages);

Likewise, to remove a ProgressListener you call engine.removeProgressListener(ProgressListener listener).

Throttling Download Speed

You can artifically slow down the speed at which data is transferred from the web server by setting the System property de.vxart.zipupdate.UpdateLocation.downloadSpeed to the maximum number of KBytes per second (1024 bytes/second) that should be used by any individual UpdateLocation instance, i.e. each instance will use that maximum speed, it is not "shared".
The value is parsed upon creation of a new instance of UpdateLocation, it cannot be changed after creation or when a download is in progress. Legal values are positive numbers, anything else will disable throttling.

Throttling is considered experimental and the connection might hang randomly. Use at your own risk.

When manually running an update, you can enable throttling by adding the following argument to your java command:


-Dde.vxart.zipupdate.UpdateLocation.downloadSpeed=200

To enable throttling from code, do this:


System.setProperty("de.vxart.zipupdate.UpdateLocation.downloadSpeed", new Long(200));

Both examples limit the download speed to a maximum of 200 KBytes per second.

Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States and other countries.