Setting up a productive environment for your web programming experience is going to be a real timesaver once you get it set up correctly. And with Eclipse you can have that Tomcat container of yours up and running with automatic deployment of beans and jsp pages in a snap. Add Maven dependency management into the mix and you have yourself a good coctail to take your mind off those tedious deploy sequences, and instead concentrate on what you love most - hacking the code.
First of all, go download Eclipse Europa, specifically the Eclipse IDE for Java EE Developers distribution. Its about 125MB last time I checked. This has all the nice tools and plugins you'll need to effectively develop JEE applications.
Okay, you're all set, eh. Now you'll need to download Apache Tomcat. We'll be working with 5.5 here, but any other version should work fine as well. So go on, and fetch that last Core distribution. Unzip/untar it somewhere and we'll go on with setting it up to work with Eclipse.
Open up your server view (Window->Show View->Other...)
And we're ready to add a server. Right click in your server view "New->Server" and select a Tomcat 5.5 and click Next. Now select your tomcat installation directory (where you unpacked that zip/tar.gz file) and you're as you click Finish.
Setting up facets
As you may, or may not know, Eclipse relies on something it calls facets for adding certain behaviours to a project. If you want your project to be able to behave as a dynamic web project, you need your project to enable the WTP nature. If you want maven, then thats another chapter.
If you are creating a new Eclipse project as a Dynamic web project this is already set up for you. But if you are checking out an already existing project then you will need to add facets to your projects. So we'll do that. In your project directory you have a file named .project. Open that, and add a link to the facet nature org.eclipse.wst.common.project.facet.core.nature. It will look something like this:
Now reload your project (F5). Right
click your project -> Properties and find the "Project Facets" editor. Here you select Dynamic Web Module and Java. And thats about it.
You're not still building your projects with ant are you? Setting up a Maven project is a bit out of the scope of this article, but I'll include some bits about setting up your Maven project in Eclipse.
You'll need to install the m2eclipse plugin. And when that is done, right click on your project and click "Maven->Enable Dependency Management". You will now notice that you will have an extra library source for your project.
But we're not quite ready yet. You might want bundle your dependencies for the project at deploy time. Meaning that the jar libraries you depend on will get copied over into the WEB-INF/lib folder. Right click your project, and select Properties again. Now go to the "J2EE Module Dependencies" and select what you want bundled.
Deploying your webapp
You are now ready to deploy your web application. Go to your servers view, right click your Tomcat instance and "Add or Remove Projects".
Select the projects you wish to deploy and you're ready to start developing.
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.