[Project_owners] Code to create jar file

Christopher Ottley xknight at users.sourceforge.net
Thu Jan 20 14:17:45 EST 2005

Martin Hassman wrote:

> Laeb wrote:
>> Does anyone knows if there is a way of creating a jar file with a 
>> code within an extension ?
> I think there is no possible to create jar (zip) file with 
> nsIZipReader, it has read-only capabilities. I do not know about 
> direct possibility how to create zip with Mozilla (only call zip 
> binary as external process or create you own binary component linked 
> with some zlib library).


Unfortunately Martin is correct. A nsIZipWriter component has been 
requested in various forms from at least 2001 (if you check various 
mailing list archives). I have plans to get one going this year sometime 
with a friend of mine, but I digress. If you want to create a zip file 
and you're willing to go way off the beaten path, you could require your 
extension users to have Java Applet support in the browser. That way 
you'd be able to take advantage of the java.util.zip package from 
javascript using liveconnect. Write an applet that provides a 
nsIZipWriter type interface. Applets don't (can't?) load from a chrome 
URL though, so you must place the Applet's jar file in the filesystem 
somewhere. Using the html namespace, extend the browser chrome, add the 
applet html code and make sure it's visible (a 1px by 1px applet should 
be basically unnoticeable) or the applet won't start. This is, of 
course, assuming you're familiar with Java and want to go through all 
that insanity. It does work though, I've used this method to call java 
code from chrome javascript for extensions I've written for my own use.
    All that said, with MAF I use the external process method Martin 
mentioned to zip files.

Good luck either way,

More information about the Project_owners mailing list