Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make a WAR file for a web app

 
Niranjan Deshpande
Ranch Hand
Posts: 1277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i am reading chapter 11. I was thinking to try to make a WAR file for one of my web app ( named myApp )

i know the steps involved in this -

1) make a JAR file for the complete web app ( everything below the myApp directory should go inside the JAR file )
2) rename the JAR file with ,war extension and let the name of the file be the name of your web app
3) drop the WAR file into your web apps directory and its all done

but my questions is How do i put all the stuff ( below myApp directory ) into a JAR file.

i got this help when i executed the jar utility in the JDK/bin folder

Example 1: to archive two class files into an archive called classes.jar:
jar cvf classes.jar Foo.class Bar.class

where c,v,f are the flags. They mean -

-c create new archive
-v generate verbose output on standard output
-f specify archive file name

The above exampl illustrates to put two .class files into a JAR. but what if myApp has directories and sub directories ? how do i put these into a JAR. I think this can be easily done using IDE like WSAD or Eclipse. But how do we do it using the process given above ?

Please help

Thanks in advance
Niranjan
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you ever used ant ? It really helps to make JAR/WAR files in no time.
There's a war task where you can set everything to make a deployable application. Have a look at Ant's homepage for all the details. And you can surely find lots of samples on the net.
 
santhoshkumar samala
Ranch Hand
Posts: 156
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

to create war file follow these steps

for example if your application name is example and it is in C:\
your application directory should be like

c:\example\ ---->all jsps and htmls should go here

c:\example\WEB-INF\classes\ --->put all your classes here, if you dont use any packages, if you use a package called foo.bar then the corresponding class should go in c:\example\WEB-INF\classes\foo\bar\

c:example\WEB-INF\lib\ --->put all the jar files here

c:example\WEB-INF\tags\ --->put tag files here

c:examples\WEB-INF\tlds\ --->put tld files here

after all these open command prompt and goto c:examples and type following in comand prompt

c:example>jar -cvf example.war .

dont forget to put "." after war(there should space and then period symbol)

It will create a war file with name example.

hope this helps..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic