Stupidly Simple WAR files
Overview
WAR files are ways to deploy a project onto a Tomcat server. They contain all necessary JSP pages, java classes, jar files, etc. to run a service. I always have an issue with creating them since it can be confusing setting up the proper directory structure, making sure everything is in place, etc. This is the quickest way I know to create WARs without needing an IDE.
Process
- Create a new directory (Referred to as foo from now on) and copy all your JSP files there.
- In foo, create a directory WEB-INF/lib
- Copy all jar files you are dependent on into WEB-INF/lib/
- Create a jar of your source. For example if your project's compiled class files are in a directory called bar you would run: jar -cvf bar.jar bar/
- Copy bar.jar to WEB-INF/lib/
- In the bar directory run the following command jar -cvf projectName.war .
- Drop projectName.war into webapps in Tomcat and restart Tomcat, and you should be set.
Conclusion
As trivial as this seems I couldn't really find an easy breakdown online. Some purists may not like that the directory structure isn't full (No meta-inf, web.xml, etc.) and that I used a jar instead of classes.
Comments(0)
2009-07-15 00:44:50