Re: update jar file with java code
Mark Space wrote:
IchBin wrote:
Not sure if this will help.. This may get you started. I have not
worked with the java.util.zip classes yet. I maybe wrong but you can
not update a zip file. You have to extract and build a new one and add
new files items. Again I am sure someone can correct me. The book from
Well good answer there, IchBin. I haven't worked with the zip classes
either, I just assumed that there'd be a "add" method. But nope,
there's delete and read but no write. What a bummer. It looks like
someone at Sun got bored and wandered off before the API was done.
Does that matter for the O.P.'s purposes? Yes, he said
he wanted to "update an existing big jar" -- but in truth,
that doesn't seem to be what he needs at all! He's writing
a servlet to send a jar to a client, and he apparently wants
to "fingerprint" each jar with a client-specific entry. So
what he really needs, it seems to me, is a read-only jar on
the server that he can copy entry by entry from (probably) a
ZipInputStream to a ZipOutputStream. Along the way he can
synthesize and write his one extra "fingerprint" entry to the
ZipOutputStream. The jar that's sent to the client never gets
written to the server's storage, never needs to be updated on
the server -- it's just a transient, in-flight "fire and forget"
stream of output that happens to have the form of a zip file.
... or have I completely misunderstood the intent?
--
Eric Sosman
esosman@acm-dot-org.invalid