This post shows how to export a dynamic web project in Eclipse Neon to a WAR file (Web Archive). The WAR export can be configured to include dependent JAR files (Java Archive). The WAR file (aka Web Module) can then be deployed to an application server, here Tomcat 9, to run the web application.
- Configure Deployment Assembly for Dynamic Web Project
- Export Dynamic Web Project to WAR File
- Export a Java Project in Eclipse Neon to Executable JAR File with Manifest
- Setup Java IDE with Eclipse Neon and Tomcat
- Creating a Java SOAP Service with Eclipse and Tomcat
- Create JAX-RS Java REST Service with Eclipse and Tomcat
1 Configuring Deployment Assembly for Dynamic Web Project
- An Eclipse Neon web project with Spring 5 MVC support is used to show how to export to a WAR file.
- For step-by-steps instructions on how to create a web project with Spring in Eclipse Neon, see the post:
- There is a controller called
MyController.javaand a JSP called
- Two user libraries called
Spring5have been created and added to the build path.
- Right-click on the project name, here
SpringWebProjectand select Properties in the context menu.
- Select Deployment Assembly on the project properties dialog.
- The dependent user libraries need to be added here so that they are included in the WAR file.
- Click on the Add button to create a new Assembly Directive.
- From the list of Directive Types, select Java Build Path Entries and click Next.
- Select the user libraries, here
JSTL-1.2.5and click Finish.
- Click on OK to complete the deployment assembly configuration.
2 Export Dynamic Web Project to WAR File
- In the Eclipse Neon Project Explorer, right-click on the project name and select Export > WAR file from the context menu. For more information on WAR files, see The Java EE 5 Tutorial on Web Modules by Oracle.
- Use the Browse button to select the destination for the new WAR file and then click on Finish.
- The WAR file will be created in the specified destination folder.
- The WAR file can be unzipped using the Archive Utility on Mac OS or the Windows ZIP tool.
- The screen shot below shows the content of the WAR file, including the JAR library dependencies.
- The WAR file can now be deployed to a Servlet Container such as Tomcat or to a Java EE compliant Application Server such as JBoss.