wood burning stoves 2.0*
The moose likes Ant, Maven and Other Build Tools and the fly likes create a war file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "create a war file" Watch "create a war file" New topic
Author

create a war file

shekar march chandra
Greenhorn

Joined: Jul 07, 2005
Posts: 25
Hi,

Can anybody have idea, how to create a war file in eclipse.

Thanks,
Chandra
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I can tell you how to do it from the command line:

Cd to the root of your webapp.
Type:
jar cvf MyApp.war *


For something Eclipse specific, you might want to check out our IDEs forum.
http://www.coderanch.com/forums/f-12/vc
[ August 31, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You probably just want to create an ANT script and run it from inside Eclipse.
shekar march chandra
Greenhorn

Joined: Jul 07, 2005
Posts: 25
Hi,

David i think you are right. Can u tell me how to write an ant script.

Thanks,
chandra
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This isn't really a servlet question, it could be either an ANT or Eclipse question (as it currently stands).

I'll move this question to the Ant, Maven and Other Build Tools forum, we'll continue the conversation over there.

Dave
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Here now

Without knowing how much ANT you've done:

1) In the root of your project (or the root of your war file, or where ever is appropriate) create a new file called build.xml. It can ce called something else, but Eclipse automatically treats build.xml files as ANT files.
2) Paste the following and edit to taste. It assumes the build.xml is in the project root directory and class files for the WAR are in the 'build' directory, the jsps are in the 'jsp' directory and the web.xml is in src/web.xml and the war file will be placed in the project root and be called 'my.war'

Note that I just paraphrased the ant instructions here



Now if you open the file in the Eclipse ANT editor and have the 'Outline' view open as well, you can right click the 'build_the_war' target and select 'Run as'> and then Ant. VIola, a war should appear. (I hope )

Dave
shekar march chandra
Greenhorn

Joined: Jul 07, 2005
Posts: 25
Hi David,

Really I was wondering how to write Ant script for creating war file.

After your suggestion and help, I was really happy.I followed the procedure told by you and created the war file and got deployed successfully in weblogic server.

Once again, Thanks a lot for your help.

By the way, I had doubts:

1. whats the difference between tomcat project and web project.

2. Is the procedure same even for ejbs.

Thanks,
Chandra
 
Don't get me started about those stupid light bulbs.
 
subject: create a war file
 
Similar Threads
Packaging?
project dependencies ?
Building a .WAR file
servlets
on war file