Вопрос

I have a jar file which contain another jar inside:

abc.jar --> a.class, b.jar, c.txt

which a.jar --> x.class, y.class

I want to add new class file z.class into a.jar & return abc.jar with updated a.jar

1 way is that extract & pack again.

Can I do it on-fly without extracting?

Это было полезно?

Решение

The Jar tool provides a u option which you can use to update the contents of an existing JAR file by modifying its manifest or by adding files.

The basic command for adding files has this format:

jar uf jar-file input-file(s) In this command:

The u option indicates that you want to update an existing JAR file. The f option indicates that the JAR file to update is specified on the command line. jar-file is the existing JAR file that's to be updated. input-file(s) is a space-delimited list of one or more files that you want to add to the Jar file.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top