20 October 2010

Importing GWT SDK Samples into Eclipse

I've recently started working with the Google Web Toolkit (GWT), which seems pretty sweet from everything I've read so far. It has great integration with an IDE, in this case Eclipse, which is absolutely essential.

Unfortunately, it was hard to find a way to easily open GWT's sample projects in Eclipse, but after a little trial and error, here is what I came up with. For each sample project you want to use, do the following:
  1. Create a new Java project with the name of the sample project you want to use, for example, "Hello". Use all the other default settings, and press "Finish".
  2. Right-click on the project and choose "Import". Choose "General" -> "File System", then press "Next".
  3. Browse to the directory of the sample project you want to import. On my computer, the project was found at something like: C:\Program Files\eclipse\plugins\com.google.gwt.eclipse.sdkbundle...\gwt-2.0.4\samples. Select all, then press "Finish".
  4. Right-click on the project and choose "Google" -> "Web Toolkit Settings". Check the "Use Google Web Toolkit" check box.
  5. Go the the "Java Build Path" section of the project's properties. Change the default output folder to something like: "/Hello/war/WEB-INF/classes" (This will be different depending on your project name).
That's all! Good luck and have fun trying out GWT's samples.