This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes Packing and Unpacking WAR files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "Packing and Unpacking WAR files" Watch "Packing and Unpacking WAR files" New topic

Packing and Unpacking WAR files

Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hello, Can anyone tell me how to do this.
i've placed the files I want in one folder and I've typed in the command line :
jar cvf test.war ServletSimplePublisher.class SimplePublisher.html web.xml
is it correct to copy all files you r gonna pack in a folder and then jar it?
Now, I've got a test.war file. How do I unpack it?

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

You don't have the correct WAR file structure, your WAR needs to look something like this:

Then to jar it you can type:
jar cvf test.war *
jar cvf test.war SimplePublisher.html WEB-INF/web.xml WEB-INF/classes/ServletSimplePublisher.class WEB-INF/src/
There's no need to unpack your WAR file in order to deploy it to your application server. But, if for some odd reason you want to explode the WAR, you can use a program such as WinZip, or you can use the jar tool:
jar xvf test.war
The HP Application Server comes with some great TrailMaps that will introduce you to WAR files, their structure, and how they work. HP-AS also comes with a deployment tool called RadPak that makes creating and deploying WAR files quite easy. -- And better yet, HP-AS is totally free.
[ February 14, 2002: Message edited by: Jessica (Bradley) Sant ]

- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Mike Monali

Joined: Feb 15, 2002
Posts: 4
Is it possible to use Apache's ANT for this purpose? Does anyone know how to do this? Thanks!
Steve Fahlbusch

Joined: Sep 18, 2000
Posts: 595

Ant can be used to copy files, make directories, complile source, run tests, pack into jars, wars
and ears.
I you want a detailed intro to how to get ant
to do all this look at: Java Tools for eXtreme
Programming (Hightower & Lesiecki )
I agree. Here's the link:
subject: Packing and Unpacking WAR files
jQuery in Action, 3rd edition