Extract jar to specified directory

I wanted to extract one of my cans to the specified directory using the jar command-line utility.

If I understand this right -C , the option should be a trick, but when I try

 jar xvf myJar.jar -C ./directoryToExtractTo 

I get usage information from my jar utility, so I am doing something wrong.

I want to achieve the goal using jar or I need to manually move my jar and call there

 jar xvf myJar.jar 
+44
java command jar
Apr 05 '13 at 9:56 on
source share
4 answers

Better to do it.

Browse to the desired folder structure

Use command

 jar -xvf 'Path_to_ur_Jar_file' 
+38
Apr 05 '13 at 10:05 on
source share
β€” -

jars uses ZIP compression, so you can use any unzip utility.

Example:

$ unzip myJar.jar -d ./directoryToExtractTo

+36
Apr 05 '13 at 11:06 on
source share

There is no such option in the jar command. See the documentation :

-C dir Temporarily changes directories (cd dir) during jar when processing the next inputfiles argument. Its operation should be similar to the -C UNIX tar utility option. For example: jar uf foo.jar -C classes bar.class changes to the class directory and add bar.class from this directory to foo.jar. The following command: jar uf foo.jar -C classes. -C bin xyz.class changes the class directory and adds all the files in the class directory to foo.jar (without creating classes, the directory in the jar file), and then returns to the original before going to the bin directory to add xyz.class to foo. jar. If the classes contain the files bar1 and bar2, then here is what the jar file contains jar tf foo.jar: META-INF /

META-INF / MANIFEST.MF

BAR1

bar2

xyz.class

+8
Mar 24 '15 at 18:56
source share

It worked for me.

I created a folder and then changed it to a folder using the CD option from the command line.

Then run the jar.

 d:\LS\afterchange>jar xvf ..\mywar.war 
-one
Apr 12 '16 at 5:05
source share



All Articles