Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extract directory from jar file

Tags:

java

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?

like image 421
Hans Avatar asked Sep 21 '25 07:09

Hans


1 Answers

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  
like image 54
Haim Raman Avatar answered Sep 22 '25 20:09

Haim Raman