简体   繁体   中英

Updating .class file in a jar throws exception

I'm trying to port a wikimedia plugin to run on OpenVMS and needed to alter a class. I'm trying to update the .class file in the jar using jar uf jar-file .class-file , however when I do this I get the following:

java.util.zip.ZipException: duplicate entry: META-INF/LICENSE.txt
        at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:175)
        at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:90)
        at sun.tools.jar.Main.update(Main.java:507)
        at sun.tools.jar.Main.run(Main.java:184)

It turns out there are 2 LICENSE.txt files in the jar and I can't seem to get rid of them.

Any ideas on how to just get the new .class file into the jar or how to get rid of the duplicate file?

A jar file is just a zip, so unzip the JAR and then re-package it. Or open it with any graphical zip file utility and remove the duplicate entry.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM