3

I have searched for this for a while now, but cant seem to figure it out. I want to extract a directory from a jar/zip file, and save it recursively to a path on the filesystem in java. Anyone know how I might do this?

Hans
  • 335
  • 4
  • 11

2 Answers2

5

I know that the original question was actualy doing this programmatically.

But as it wasn't clear enough I guess many users (like me) ends up here when they just want to unzip a directory out of the jar using the jar command.

jar -xvf   <your>.jar  <required-dir>

E.g. extract META-INF directory out of some.jar

jar -xvf   some.jar  META-INF

to list the content of the jar use

jar -tvf   some.jar  
Haim Raman
  • 10,970
  • 6
  • 43
  • 64
4

An answer from this thread might give a good feeling how/where to start:

Simply put, it's java.util.jar you're looking for.

Community
  • 1
  • 1
fbahr
  • 821
  • 1
  • 8
  • 12