I’m trying to update (add/modify files) an existing JAR file, and this code (using the DotNetZip library) results in the archive being “corrupted”, I cannot open it with WinRAR as a ZIP or a JAR:
using (FileStream fs = new FileStream("/path/to/jar", FileMode.Open))
{
ZipFile zip = ZipFile.Read(fs);
fs.Seek(0, SeekOrigin.Begin);
zip.Save(fs);
}
Can anyone tell me what the difference between the ZIP and JAR format is, exactly? I was under the impression it was simply the ZIP format with the manifest as the first entry in the file, which is apparently not the case. Is there an existing (C#) library I can use to do this?
A JAR is binary compatible with a [“standard”] ZIP archive. Only the optional Manifest file is prescribed, but this will not cause a “corrupt archive”.
I believe one (or both) of these is happening:
(Zipping it to a new file would allow this to be verified.)