Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to create war file in eclipse using ant

Posted on 2010-01-12
3
Medium Priority
?
1,522 Views
Last Modified: 2013-11-10
Hi,
I have created a web application in my my eclipse environment. In my eclipse I am running it with tomcat. I need to build a war file which I then can deploy on tomcat server which is on solaris box.

Attached document has a directory structure

Thanks
directoryStructure.jpg
0
Comment
Question by:AjooAli
3 Comments
 
LVL 1

Accepted Solution

by:
him6ul earned 2000 total points
ID: 26299609
Ant has a WAR task which you can use to create your WAR file.

Not sure why you want to use eclipse if you are anyways using ANT to create WAR - eclipse has task to call an ant file from IDE itself.
0
 
LVL 2

Expert Comment

by:malaki12003
ID: 26300466
Create an ANT script that will look at the Eclipse Project structure and build the WAR file and copy over the WAR file to the destination (Tomcat WebApps folder)

Here is the ANT script:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Deploy From Eclipse to Tomcat" basedir=".">
<property name="warfile" value="sanfran"/>
<target name="unpack">
<unwar src="${warfile}.war" dest="${warfile}" />
</target>
<target name="create">
<war destfile="${warfile}.war" webxml="WebContent/WEB-INF/web.xml" update="true">
<classes dir="build\classes"/>
<fileset dir="WebContent">
<exclude name="WEB-INF/web.xml"/>
</fileset>
</war>
</target>
<target name="copy">
<copy todir="c:\tomcat5517\webapps" overwrite="true">
<fileset dir=".">
<include name="*.war"/>
</fileset>
</copy>
</target>
<target name="deploy">
<antcall target="create"/>
<antcall target="copy"/>
</target>
</project>

Save the above code into a file and name it build.xml. Place the build.xml into the root folder of your eclipse project. For example, if c:\projects is my eclipse workspace and SanFrancisco is the name of my project then all the files related to the project will be under c:\projects\SanFrancisco.
0
 
LVL 40

Expert Comment

by:Gurvinder Pal Singh
ID: 26300552
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question