GWT - Google Web Toolkit
From Giews
Google Web Toolkit (GWT) is a framework which allows to create an AJAX client for a web-application by means of Java language. GWT libs provide translation from Java to JavaScript.
Contents |
[edit] HowTo: Create a new application
This is a really quick tutorial to create a GWT application.
- Download GWT libs for your OS at GWT Home.
- Create a new folder in your workspace, e.g. GWTTutorial.
- Extract the lib you downloaded in GWTTUtorial.
- There are two important files now in the folder: projectCreator and applicationCreator (the extension is up to your OS)
- Open a terminal and move to you GWTTutorial folder. First of all we have to create the project, like this:
- projectCreator -eclipse GWTTutorial
- We have now an Eclipse project, we need to create a GWT application:
- applicationCreator -eclipse GWTTutorial tld.mywebsite.client.GWTManager
Take a while to navigate your project folder. In the root you'll find 5 new files which are:
- .project
- .classpath
- GWTTutorial.launch
- GWTTutorial-shell
- GWTTutorial-compile
These files are in the root, but new files have been created in the src sub-folder too:
- /src/tld/mywebsite/GWTTutorial.gwt.xml
- /src/tld/mywebsite/GWTTutorial/client/GWTManager.java
- /src/tld/mywebsite/GWTTutorial/public/GWTTutorial.html
The XML file is provided to configure the application, GWTManager.java is the entry point, the first class to be loaded by GWT, while the .html file is a wrapper for GWT code.
[edit] HowTo: GWT and Eclipse
To import our GWTTutorial project into Eclipse just do the following:
- File -> Import -> General -> Existing Project into Workspace
and select your GWTTutorial folder. In your root folder you'll find GWTTutorial.launch. Right-click on it and select
- Run as -> GWTTutorial
GWT hosted mode will be loaded and you'll see a welcome page (the .html wrapper).
[edit] Running GWTcompile from within Maven
Please refer to this page.
[edit] OS Dependencies
There are three GWT distributions: Windows, Linux and Mac OS X. Main differences between distributions are:
- gwt-dev-xxx.jar, where xxx can be windows, linux or mac.
- scripts, like applicationCreator or projectCreator, them embed references to GWT OS dependent libs.
Each time a project is moved from an OS to another one scripts must be changed to update references to the right OS libs. During development time the most important file to update is ProjectName.launch which allows to run the hosted mode to debug the application and to compile it. I think the fastest way to upgrade the scripts is to delete and re-create them, by means of -ignore option. E.g.
- delete ProjectName.launch
- delete ProjecName-compile
- delete ProjectName-shell
Then, open a terminal, move to the project folder and run
- applicationCreator -eclipse GWTTutorial tld.mywebsite.client.GWTManager -ignore
By means of this option the application creator doesn't overwrite the .gwt.xml configuration file, the .java entry point and the .html wrapper, in order not to lose all your (hard) work. This is a raw solution to update the .launch file but (most of times) works.
[edit] Client and Server
[edit] Client Restrictions
All the .java classes which are in the client folder of a GWT application must:
- contain only Java 1.4 code,
- implement Serializable or IsSerializable interface,
- have an explicit public empty constructor.

