File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How can I make a war file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can I make a war file?" Watch "How can I make a war file?" New topic

How can I make a war file?

Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
How can I make a war file?

I tried:
% jar cf webapp.jar webapp

and then rename webapp.jar to webapp.war, but the webapp won't run under tomcat. When I decompressed the webapp.jar with a tool, I found all the directories inside webapp.jar were placed in Tomcat's webapps directory, not in webapps/webapp.

I tried posting a similar question the Ant forum because i'm using Ant, but I don't have to use ant, I just have to make a war file.

comp.lang.javascript FAQ:
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Please don't cross post. See the post in the Ant forum for a question I posed.

[Asking smart questions] [About Bear] [Books by Bear]
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
The question here is related to the command line.

The question I posted in the Ant forum is related to Ant.
Tarun Gandhi

Joined: Jan 13, 2003
Posts: 13
You can try:

cd webapps/webapp
jar cf ../webapp.war *

This will make a war file containing the contents of webapp and store it in the webapps directory. (Thanks Rusty Enisin. I misunderstood the question.)
[ August 02, 2005: Message edited by: Tarun Gandhi ]
Rusty Enisin
Ranch Hand

Joined: May 26, 2005
Posts: 107
I think you have to make the war file like this:

This will put the war file in the webapps dir. If you want it some place else, change ../ to some place else.

Doing it the way mentioned in the previous post will not create a well formed war file. I am not sure, but I think it will not even run.

The squeaky wheel gets the grease. Well, that or replaced...
I agree. Here's the link:
subject: How can I make a war file?
It's not a secret anymore!