How to deploy a Eclipse Java Web Dynamic Project

Follow the steps below:

  1. Setup Apache Tomcat
  2. Export your web application .war file
    • In Eclipse, right click on a Web project and select Export. Then select WAR file in the Export window and then select Next. Choose the project, the .war file name and folder to export. More detailed explanation can be found here and here (with pictures).
  3. Deploy the .war file to your Tomcat Server
    • The, by far, simplest way to do this is to place your .war (say myapp.war) file in your apache-tomcat-folder\webapps\ folder.
    • There are other ways, like via Tomcat Manager. But they can be tricky and, as a new user, you should avoid them. (Don’t worry: the simple method is ok for production deployment).
  4. Test your web app

That’s it. If you ever edit the app, repeat steps 2-4 (but delete the webapps\myapp\ folder created before executing step 3).

Exporting modules

Modules that are created in WTP may be exported in various ways. The following instructions focus on exporting modules as deployable artifacts. First, you must have previously imported or created a module. (For instance, a Dynamic Web Module).

Exporting a web modules

Figure 1.1: Right click on the Web module you intend to Export and select “Export > WAR File”.

Figure 1.2: Enter a destination for your *.war file and click “Finish”.

Figure 1: Right click on an existing project to export a *.war module. The Wizard will already have the Web Module you intend to export pre-selected. You may change the Web Module you would like to export in the “Web project:” drop down .

Initially, the export wizard should have the project that contains the Web Module you selected. Enter a destination for the export (e.g. C:\temp\mywar.war). When you are done, click Finish. The wizard will handle the details of constructing the Web Module per the J2EE specification. Optionally, you can choose to export the source files. Exporting source files can be useful when you intend to use the war for collaboration or like to keep a record of what is contained in the *.war file. You may verify the contents of the *.war file using your favorite Zip File client.

Each of the types of modules has their own specific Export wizard. Try exporting another type of module. For instance, you may export the *.ear file that contains the Web Module you just exported by selecting the EAR Module, right-click, and then select “Export > EAR File”. The wizard is largely similar to the Web Module Export wizard. It will construct a *.ear file that contains all of the other modules.

The artifacts produced from the export wizards are ready to deploy onto your favorite Web Container or J2EE Application Server. Some containers like Tomcat require only the *.war file to deploy, while other full-service J2EE Application Servers like Websphere Application Server require a *.ear file.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s