Tuesday, September 1, 2009

An easy way to set up a web site (using Java, Maven and Eclipse)

Download the following open source software:

* Tomcat 6 from http://tomcat.apache.org/download-60.cgi
unpack it in a local directory. (I got the Core tar.gz one)

* Eclipse (the JEE edition) from http://www.eclipse.org/downloads/
launch Eclipse

In Eclipse:

* Install the Maven (m2eclipse) plugin for eclipse by adding


as a new site under Help->Install New Software-> Add

Select the the checkboxes of the modules you want to install.

Create a new Eclipse project

* Select File-> New -> Other -> Maven Project

leave project name and location to the default values

as a project Archetype select maven-archetype-webapp

as a group ID select the name of your organisation e.g. org.biojava

Artifact ID is the name of your module. E.g.: myweb (this will also be in your servlet URL)

This will create the following servlet in your workspace.

Deploy the project on Tomcat

* Add a new Tomcat 6 server : Select File-> New -> Other -> Server

* select Apache-> Tomcat 6

* point
it to the location at which you upacked Tomcat

* add your servlet to it and press Finish

* Start your server buy either clicking the green button, or right click on your servlet project and say Run As -> Run on Server

* Tomcat will start and the servlet is running

Add new jsp pages and start the development of your servlet!

Finally: If you want to give the servlet to your sysadmin to release on a production site, just do a Right click on the project and do Run As -> Maven package . This will create a myweb.war in the target subdirectory of your project that can be deployed in stand alone tomcat instances outside of eclipse.