Setting up Eclipse for easy GWT development

Here at the Flax Project headquarters, we use Eclipse as our development environment. This is for a couple of reasons: It’s fully cross-platform, open source, it works fairly well, and it’s got a GWT plugin. While you can, technically, develop GWT web applications without using the plugin or indeed Eclipse, I can’t recommend it. Now, I’m going to walk you through setting up your IDE and making a mostly blank GWT project in Eclipse. We’ll link back to this in other tutorials for convenience.

Setting up the IDE:

  1. If you don’t already have or use Eclipse, read this to learn about installing and updating.
  2. Install Google’s plugin for Eclipse by following these handy-dandy instructions.

Hey, that was easy. Optionally, you could install Aptana as a plugin for Eclipse to make web development easier, though this isn’t a requirement. If you know your way around web development, you probably already have a favourite editor (Espresso is my current favourite), and if you don’t, it’s probably not all that necessary. However, I’ve got it installed, so that I never have to leave Eclipse. I leave this up to you.

Setting up a blank GWT project:

  1. Open Eclipse and go to File->New->Web Application Project.
  2. It’s not entirely necessary to use the Google app engine for most, if not all, of the tutorials we’ll be going through, so uncheck that unless a tutorial says otherwise. Name your project however you like and hit “Finish”.
  3. Now, you’ve already got a template app! How easy was that? If you click the green arrow in the toolbar, Eclipse will do some magic and give you a URL. If you visit this in a browser (after installing the plugin for your browser), that’s your template app.
  4. Once you’ve had fun moving the little Javascript window around, it’s time to say goodbye. This template app gets a little annoying as it creates a bunch of files that you don’t need for much development, and you can’t switch template creation off. (If you’d like to see that as an option, add your name to this list.) Delete everything under Server, Shared, and and GreetingServiceAsync from Client. Yes, all of that is unnecessary.
  5. Now, go to /war/WEB-INF/lib/web.xml and remove the references to servlets, because we deleted those.
  6. Optionally, you can edit the html and css files in WEB-INF, and you probably want to do that at some point.
  7. Delete virtually all of the code in /client/ until it looks like this (click to embiggen):

    Blank GWT Main Method

    Blank GWT Main Method

    You can regard onModuleLoad() as the “main” method.

Importing libraries

Importing libraries is fairly easy (though a little convoluted) as well. I’ll go through that here too.

  1. Download your library and place it at a useful location (for example, /workspace/extLibraries).
  2. Open whateveryounamedyourproject.gwt.xml and add your library to “Other module inherits”, like so:

GWT library example

GWT library example

You’re entirely ready to code now! How easy was that, eh? Eh?

Here are the really important parts: onModuleLoad() should be regarded as your “main” method. Virtually all of what is created as a template project is unnecessary. The green arrow in the toolbar is for debugging, and the red Google suitcase is for proper deployment.
Don’t feel like following the steps? Here’s one I prepared earlier. Note that this is just for practice and as an example, and if you’re intending to properly do this, you’d be better off doing it yourself.
Good luck!

About the Author

Carl Lange

I'm currently a Computer Games Development student at Carlow IT. I love programming and all things technical, and I'll learn anything if it's interesting. I'm passionate about technical education, and naturally about games. Check out my resume, and follow me on Twitter!

Visit Website

One Comment

Trackbacks for this post

  1. […] sure before you do this that you’re set up properly, with a blank project as detailed in this tutorial. However, the example that’s created by default makes use of RPCs, so if you just want a rough […]