Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting jar to specified directory

Tags:

java

command

jar

I wanted to extract one of my jars to specified directory using jar command line utility.

If I understand this right -C option should to the trick but when I try

jar xvf myJar.jar -C ./directoryToExtractTo 

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

Is the thing I want achievable with jar or do I need to manually move my jar and there invoke

jar xvf myJar.jar 
like image 644
Andna Avatar asked Apr 05 '13 09:04

Andna


People also ask

How do I extract a JAR file?

JAR files work just like ZIP files. You can use any archive program to extract them. On Windows, you can Install WinRAR 7-Zip, or WinZIP. Macs have their own built-in archive program called Archive Utility.

What is jar XVF command?

jar -xvf /Directory/File.zip. -x extract named (or all) files from archive. -v generate verbose output on standard output. -f specify archive file name. Note: The 'jar' command extracts to the current directory.

How do I extract an executable JAR file in Windows?

To unpackage a JAR, you need a program that can extract compressed files. Windows includes functionality for this, but you can also use file extraction software like 7-Zip or WinRAR to get the job done. Open the JAR file within the software, and you can browse all the folders and files within it.


2 Answers

jars use zip compression so you can use any unzip utility.

Example:

$ unzip myJar.jar -d ./directoryToExtractTo

like image 159
Amit Maniar Avatar answered Nov 15 '22 23:11

Amit Maniar


It's better to do this.

Navigate to the folder structure you require

Use the command

jar -xvf  'Path_to_ur_Jar_file' 
like image 20
Harshavardhan Konakanchi Avatar answered Nov 15 '22 22:11

Harshavardhan Konakanchi