This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Regarding Jar Utility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Regarding Jar Utility" Watch "Regarding Jar Utility" New topic
Author

Regarding Jar Utility

Naveen Koneti
Greenhorn

Joined: Apr 27, 2007
Posts: 13
Hi

I am struggling with jar utility, to unjar a jar file to a particular folder other than the current directory.Please help me.

Thanks in Advance...
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3502
    
  14
From the Jar tutorial
When extracting files, the Jar tool makes copies of the desired files and writes them to the current directory, reproducing the directory structure that the files have in the archive.

So I guess the answer is - you can't.


Joanne
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

I would say use this command "jar ?" on command prompt options will be visible after run it.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Naveen Koneti
Greenhorn

Joined: Apr 27, 2007
Posts: 13
Hi I know how to use the jar utility to unjar a jar file.But I am facing problem with destination where to place the unjarred files.In my project I need to unjar a jar file and place it in a specified directory not in the same directory.

Thanks in Advance...
[ April 27, 2007: Message edited by: Naveen Koneti ]
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3502
    
  14
See the bold part of the quote in my first post.
Darrin Cartwright
Ranch Hand

Joined: Dec 27, 2002
Posts: 107
Hi Naveen!

You just have to go at it a little backwards.
Invoke the JAR utility in the directory you want to extract the files in, rather that the location of the JAR file itself.
For instance, if you want to extract into the some/other/dir directory, change to that directory first: (cd some/other dir || dir some\other\dir ), and then call jar -xvf ../../../myjarfile.jar

Hope that helps!

Darrin


Life is good on the Ponderosa,<br />but mind where you step.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding Jar Utility