File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 3169
    
  10
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: 3169
    
  10
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
 
Similar Threads
Help for Ejb application
Help!! uploaded assignment is corrupted??
Creating Javadoc from a jar file
Where to put DTOs, Where to archieve them , what's the professional sol ?
List resources in a jar