Using Eclipse Projects

Dealing with the zipped projects bundled with the tutorials on beginning & intermediate servlets & JSP, advanced servlets & JSP, Ajax, GWT, Spring, Hibernate & JPA, JSF 1.x, JSF 2.0, EJB3, Web services, and Java 6 programming.


Overview

The code in these tutorials was created with the Eclipse IDE. I use version 3.5 (Galileo) with Java 6, but virtually all the examples should run fine in Eclipse 3.4 (Ganymede), and 80% of them should work with Java 5. If you don't already know how to use Eclipse, information on downloading Eclipse and configuring it to be used with Tomcat can be found at the coreservlets Tomcat and Eclipse tutorial. Although Eclipse or another IDE (NetBeans, MyEclipse, IntelliJ IDEA, etc.) is strongly recommended for Java EE development, none of the coreservlets code is in any way specific to Eclipse.

Importing Zipped Eclipse Projects into Eclipse

To import the zipped projects that are bundled with these tutorials, follow these steps:

  1. Download the .zip file.
  2. Open Eclipse. The projects were created in Eclipse, but the pieces can easily be copied to projects in NetBeans, MyEclipse, or IDEA.
  3. Go the the File menu and select "Import".
  4. Choose "Existing Projects into Workspace". Do not choose "Archive File" directly from "Import". Press the "Next" button.
  5. Choose the second radio button that says "Select archive file". Press the "Browse" button and navigate to the .zip file you downloaded in Step 1. Press "Next" and follow the directions from there.
  6. Most of the servlet/JSP, Ajax, JSF, Spring, Hibernate, EJB3, GWT, and Web Service projects assume that you already have Tomcat or another server configured for use in Eclipse. If you don't have this set up already, see the Tomcat and Eclipse tutorial.

Importing Zipped Eclipse Projects into NetBeans

NetBeans claims to be able to reliably import Eclipse projects. For details, please see http://netbeans.org/kb/docs/java/import-eclipse.html.

Changing Zipped Eclipse Projects into
Normal (Deployable) Web Applications

Please note that you do not have to do this if you have Eclipse or another IDE! Your IDE will handle these steps for you automatically. These steps are only for users that are not using an IDE. Use of an IDE is very strongly recommended: the time to download Eclipse, set it up with Tomcat, and learn the most basic uses will be repaid very quickly. See the Tomcat and Eclipse tutorial. But, if you really need to import the coreservlets samples into an environment that has no IDE, read on.

Eclipse projects create two extra directories at the top-level of the project: src and WebContent. To make a regular Web application, you have to move the files under src to WebContent/WEB-INF/classes, then rename WebContent to your Web app name. For example, to turn the Eclipse project facelets.zip into a normal Web app, follow these steps:

  1. Extract everything from the .zip file, resulting in a folder called facelets.
  2. Go to facelets/src and copy all folders and files.
  3. Go to facelets/WebContent/WEB-INF/classes, and paste everything copied from Step 2.
  4. Rename WebContent to facelets and move that new facelets folder to whatever location you store Web apps.
  5. Again, these steps are not needed if you use Eclipse, NetBeans, MyEclipse, IntelliJ IDEA, or another IDE. Those IDEs will handle deployment for you.

More Information

Java

Servlets & JSP

JSF
Ajax, GWT, & JavaScript

Spring, Hibernate, & JPA

Struts