Google Web Toolkit (GWT) is a Java-based development environment for developing AJAX applications. Here are some notes of my experimenting with GWT. First, I downloaded the current build from here. As of the time of this writing, that was version 1.0.21. I downloaded the Linux version. I placed the resulting expanded folder gwt-linux-1.0.21 in my ~/projects directory. I shall refer to this location as GWT_HOME.
I want to see if I can integrate this toolkit with the Netbeans 5 development environment. The first thing is to create a project using the applicationCreator script located in GWT_HOME. If you look at the contents of this script...
#!/bin/sh HOMEDIR=`dirname $0`; java -cp $HOMEDIR/gwt-dev-linux.jar com.google.gwt.dev.ProjectCreator "$@";
...you will see that all it does is invoke a Java app, passing in the command line arguments. Perhaps we can write a Netbeans script for automating new project creation? Here is the usage:
projectCreator [-ant projectName] [-eclipse projectName] [-out dir] [-overwrite] [-ignore]
- -ant
- Generate an Ant buildfile to compile source (.ant.xml will be appended)
- -eclipse
- Generate an eclipse project
- -out
- The directory to write output files into (defaults to current)
- -overwrite
- Overwrite any existing files
- -ignore
- Ignore any existing files; do not overwrite
Since NB can start a project from existing ant script, we shall use that option.
The other script we will need is called applicationCreator. It contains the following:
#!/bin/sh HOMEDIR=`dirname $0`; java -cp $HOMEDIR/gwt-dev-linux.jar com.google.gwt.dev.ApplicationCreator "$@";
Like projectCreator, it just invokes a Java app and passes in the command line arguments. Usage:
applicationCreator [-eclipse projectName] [-out dir] [-overwrite] [-ignore] className
:-eclipse:Creates a debug launch config for the named eclipse project
:-out:The directory to write output files into (defaults to current)
:-overwrite:Overwrite any existing files
:-ignore:Ignore any existing files; do not overwrite
:className:The fully-qualified name of the application class to create.
''Note:'' The final package before your class should be ''client''.
Creating a small sample project
cd ~/projectsmkdir -p test/gwt1
GWT_HOME/projectCreator -out ~/projects/test/gwt1 -ant gwttest1
GWT_HOME/applicationCreator -out ~/projects/test/gwt1 com.gnm.test.client.GwtApp1
Let's see what files got created.
cd ~/projects/test/gwt1 find . -print ./src ./src/com ./src/com/gnm ./src/com/gnm/test ./src/com/gnm/test/client ./src/com/gnm/test/client/GwtApp1.java ./src/com/gnm/test/public ./src/com/gnm/test/public/GwtApp1.html ./src/com/gnm/test/GwtApp1.gwt.xml ./gwttest1.ant.xml ./GwtApp1-shell ./GwtApp1-compile
Now we need to start NB. Select File/New Project. Select General/Java Project with Existing Ant Script and click Next>. Browse for Location and select the ~/projects/test/gwt1 directory we created. Browse for Build Script and select the ant build script inside that folder gwttest1.ant.xml. Click Next> twice. Click Add Folder... next to Source Package Folders and select the src folder. Then click Finish.
Now all of this worked. However there are no targets set up that let you run or debug your application in NB. Rather than trying to reinvent the wheel from scratch, I did some searching an found this post by Roumen. I downloaded the NB template from this link. The name of the downloaded file was org-netbeans-modules-gwttemplate.nbm.
In NB I selected Tools/Update Center. Click on Install Manually Downloaded Modules and click Next>. Click Add and select the module file. Then click Next>. Follow through the rest of the installation procedure.
Now let's try and create a project. Choose File/New Project. Select Web/Google Web Toolkit Application. Follow the very intuitive prompts. This created a nice project, but I received an error when I tried to run it. I figured the issue may be that I was using NB with the AMD 64 bit version of the JDK. So I downloaded and installed the 32 bit JDK.
Upgrading to new GWT build
On 2006-08-14 I downloaded gwt-linux-1.1.0. The previous version I had was gwt-linux-1.0.21. Since my NB plugin had asked me for the location of gwt on my computer I figured there were some configuration files that needed to be updated.
First I did a grep for 'gwt-linux' in my ~/.netbeans/5.0 directory. I found a reference in the file build.properties:
libs.GWT.classpath=/home/gordy/projects/gwt-linux-1.0.21/gwt-user.jar
I changed it to read:
libs.GWT.classpath=/home/gordy/projects/gwt-linux-1.1.0/gwt-user.jar
Then I opened an existing GWT/NB project and resolved the broken references by pointing to the libraries from the new folder. Everything then built and ran fine.
