• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How to Extracting a *.war via "jar -xf" to another directory

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I'm have the following:
cd /home/temp/
ls
diego.war(a war file called diego) diego(a directory called diego)

If i do the following:
jar -xf diego.war

It will extract its contents into /home/temp...however I want it in /home/temp/diego.

How can i extract the contents not in the current dir but one of my choosing?

UNIX....I'm doing this via rpm spec file. Thanks
 
Diego Bowen
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually answer my own questions....in any event

unzipping will do the same thing and it provides an option to define alternate directories for the extraction:

unzip foo.war -d /home/foo
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I usually do it the other way around. cd to the directory of interest and then unjar the desired file from its location.

cd /home/temp/diego

jar -xf /home/temp/diego.war

or

jar -xf ../diego.war
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is an ancient post, but I just made a small script to recursively explode an ear/war/jar/zip and thought it might be of use to someone finding this thread.

#!/bin/sh
#

if [ ! "$1" ];
then
echo No ear file specified.
exit 1
fi

if [ ! -f "$1" ];
then
echo Specified file does not exist or is not a file.
exit 1
fi

if [ ! "$2" ];
then
echo No destination directory specified.
exit 1
fi

if [ ! -d "$2" ];
then
echo Destination directory does not exist or is not a directory.
exit 1
fi


unzip "$1" -d "$2"
find "$2" -type f -name "*.war" -exec mkdir "{}.exploded" ';'
find "$2" -type f -name "*.war" -exec "$0" '{}' "{}.exploded" ';'
find "$2" -type f -name "*.jar" -exec mkdir "{}.exploded" ';'
find "$2" -type f -name "*.jar" -exec "$0" '{}' "{}.exploded" ';'
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic