IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes How to Extracting a *.war via Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "How to Extracting a *.war via "jar -xf" to another directory" Watch "How to Extracting a *.war via "jar -xf" to another directory" New topic
Author

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

Diego Bowen
Ranch Hand

Joined: Aug 19, 2003
Posts: 50
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

Joined: Aug 19, 2003
Posts: 50
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
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1340
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
Osuwari Inu
Greenhorn

Joined: Jun 20, 2005
Posts: 13
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" ';'

Quis custodiet ipsos custodes?
 
IntelliJ Java IDE
 
subject: How to Extracting a *.war via "jar -xf" to another directory
 
Threads others viewed
How to check, TOMCAT is running as welcome page not coming
How to view jar files
unzip war files
Extract Jar File Contents
Classloading, WAR file extraction
Two Laptop Bag

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture