I have done a great deal of client oriented Swing-based work over the years. I admit to really enjoying this, as you get immediate feedback in terms of the UI you are developing and, when run within tools like Eclipse, a very rich development environment. I have always really liked the speed with which you can change some code, run it, debug it, make a change and continue debugging. This can be really useful for sorting out those niggly little logical or behavioural issues.
Of course, despite being a hardened Swing programmer I too find the latest buzz around AJAX interesting; but am still left feeling that the whole programming model is at too low a level. It reminds me of the way in which I used to code X Windows applications nearly 20 years ago. What I really want from a Web 2.0 development environment is something at a higher level, more like Swing but for web applications.
GWT provides four primary components, these are:
- GWT Hosted Web Browser – this is a runtime environment that allows the pure Java client to execute within a browser-like test environment. It is essentially a special browser control (an Internet Explorer control on Windows or a Gecko/Mozilla control on Linux) with hooks into the JVM.
java.langpackage and a subset of the
java.utilpackage are provided.
- GWT Web UI class library – this is a set of interfaces and classes that support the creation of client GUIs with buttons, text boxes images, text, tabbed panes etc. As such, it replaces the AWT, Swing or SWT classes in desktop client GUI development. GWT ships with the complete source code for the library under an open source license.
GWT applications can be run in two modes:
- Hosted mode - In hosted mode, a GWT application is implemented as a pure Java application running within a single JVM. GWT implements hosted mode by providing a simple web server like component (the GWT Development shell) and special web browser. This allows you to view and test your application within a pure Java world using tools such as Eclipse and the Eclipse debugger (see below).
To develop a GWT application, the normal development cycle would be:
- Using an IDE such as Eclipse, create the GUI client, execute, and test and debug this within the IDE's debugging environment/runtime environment. Once you are happy with the behaviour of the client …
- Test your application in each supported web browser.
The easiest way to get started with GWT is to create an appropriate application structure, which can be done in any IDE. However, GWT comes with direct support for the Eclipse IDE, which is what we'll use in the example below.