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:
- If you don’t already have or use Eclipse, read this to learn about installing and updating.
- 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:
- Open Eclipse and go to File->New->Web Application Project.
- 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”.
- 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.
- Now, go to /war/WEB-INF/lib/web.xml and remove the references to servlets, because we deleted those.
- Optionally, you can edit the html and css files in WEB-INF, and you probably want to do that at some point.
- Delete virtually all of the code in /client/whateveryounamedyourproject.java until it looks like this (click to embiggen):
You can regard onModuleLoad() as the “main” method.
Importing libraries is fairly easy (though a little convoluted) as well. I’ll go through that here too.
- Download your library and place it at a useful location (for example, /workspace/extLibraries).
- Open whateveryounamedyourproject.gwt.xml and add your library to “Other module inherits”, like so:
You’re entirely ready to code now! How easy was that, eh? Eh?