Deploying java web app to Tomcat using WAR files

Deploying your App to Tomcat as a Web Application Archive (WAR) file

When you deploy your Java web apps, you can make use of a Web Application Archive (WAR) file.

The Web Application Archive (WAR) file is a compressed version of your web application. It uses the zip file format but the file has the .war extension.

If you are using Eclipse, then the best way to visualize it is think of your "WebContent" directory being compressed as a zip file with the .war extension.

This includes all of your web pages, images, css etc. It also includes the WEB-INF directory which includes your classes in WEB-INF/classes and supporting JAR files in WEB-INF/lib.

The WAR file format is part of the Java EE / Servlet specification. As a result, all Java EE servers support this format (ie jboss, weblogic, websphere, glassfish and tomcat).

Below, I provide the steps on how to create a WAR file in Eclipse. I also show how to deploy the WAR file on Tomcat.


  1. In Eclipse, stop Tomcat

  2. Right-click your project and select Export > WAR File

  3. In the Destination field, enter: <any-directory>/mycoolapp.war

  4. Outside of Eclipse, start Tomcat

  • If you are using MS Windows, then you should find it on the Start menu
  • if in Mac/Linux/Unix
To Start server: <Tomcat Root>/bin>./catalina.sh start
To Stop server: <Tomcat Root>/bin>./catalina.sh stop
  1. Make sure Tomcat is up and running by visiting: http://localhost:8080

  2. Deploy your new WAR file by copying it to <tomcat-install-directory>\webapps

Give it about 10-15 seconds to make the deployment. You'll know the deployment is over because you'll see a new folder created in webapps ... with your WAR file name.

  1. Visit your new app. If your war file was: mycoolapp.war then you can access it with: http://localhost:8080/mycoolapp/
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容