Ilya
Ilya

Reputation: 29693

Remove file from *.jar, using script

I have next package structure

webService.ear -- dependency.jar -- some.class

Can I remove some.class from .ear using cmd script and bash script?

Solution:
I wrote cmd script for this:

call unzip target\webService.ear -d tmp
call zip -d target\tmp\dependency.jar \com\mypackage1\MyClass1.class
call zip -d target\tmp\dependency.jar \com\mypackage2\MyClass2.class 
call jar cvfM target\webService.ear -C tmp .

May be, this will be helpful for someone

Upvotes: 2

Views: 3183

Answers (1)

Jim Garrison
Jim Garrison

Reputation: 86774

There is no option to the jar command to remove entries.

However, the jar format is processable with zip tools, so you should be able to use a command-line zip (GNU zip, for instance) to remove members.

Upvotes: 5

Related Questions