Thursday, February 21, 2008

Importing existing GWT projects into Eclipse in 30 seconds (or: How to really really read the docs!)

Yesterday I wanted to import some Google Web Toolkit sample projects into Eclipse. Easy, isn't it?

I was at a customer's site and my purpose was to show them what GWT is and a bit of what it is capable of. So, I downloaded the latest GWT (1.4.61) and installed it.

Edit: As a side-note for those who do not know GWT yet, this is a truly revolutionary way to develop web applications. You code in Java, much in the same way you would code a Swing app. Then a compiler translates your Java code into Javascript, so that it can be executed in the client browser! And it does so taking into account all the details of different browsers' quirks and differences. Basically, you code and - even more importantly - debug your application in Java, and then deploy it as a Web 2.0 Javascript application!

My customers use a well-known IBM product based on Eclipse, so they wanted to see GWT code in Eclipse.
Now, GWT has a nice samples directory, so what I wanted to do was to load the first sample ("Hello") as an Eclipse project. I vaguely remembered that there was some script which could generate Eclipse-related files, so I checked the docs for it.

So I started from the Getting Started guide (no less!) and skimming through it I found this:

GWT ships with a command line utility called applicationCreator that automatically generates all the files you'll need in order to start a GWT project. It can also generate Eclipse project files and launch config files for easy hosted mode debugging, as described below.
Okay, that's it!

I started applicationCreator without arguments, and it printed:

Missing required argument 'className'
Google Web Toolkit 1.4.61
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

So after checking the script parameters, here's what I did, in a new empty directory:
> applicationCreator.cmd -eclipse Test com.example.client.Test
This created a convenient project structure, and even a Test.launch Eclipse launch configuration file, but there was no trace of a .classpath or a .project file.

I tried to import the project into Eclipse anyway, but of course there was no project to be imported! Strange... Why is the launch file generated without a corresponding project file? I began to suspect that there might be a bug (oh, suspicious me!).

I tried to hack a project file, but I was basically on my own there and I had only so many minutes before losing my audience. I was literally losing my opportunity of promoting GWT to these people, and over a detail!

Well, to make a long story short, after some moments of perplexity I resorted to googling about this, and I quickly found this interesting Issue 443! Here is an excerpt from what a user reported:
Basically, I got confused about how projectCreator and applicationCreator were related to one another. The text implies that applicationCreator generates an Eclipse project file, but that's what projectCreator does.
Great! What happened was that I too was confused by the wording in the guide into thinking that applicationCreator can generate Eclipse project files. (Read it again!)

What the guide is really trying to explain is this: GWT ("It") can also generate a project as described below. "Below" means in the next section of the guide, which talks about the projectCreator.

After discovering this, it was easy. In fact, those scripts can be run even on an existing GWT source tree!

So, in the original samples/Hello directory I did:

> projectCreator.cmd -eclipse Hello

> applicationCreator.cmd -eclipse Hello -ignore

VoilĂ , the existing sample Hello was augmented with an Eclipse project structure! (Note the -ignore option above, used to work on an existing directory structure.)

Lessons I learned for the future:
  1. Read the docs carefully and don't jump to conclusions.
  2. If you are stuck and the project has an issue tracking system, check it!
  3. Don't try to hack your solution, only to search the forums after that. Do it the opposite way!
  4. Don't think that you already knew this ;-)

Digital Ethnography: The Machine is Us (one year later)

About one year ago, Michael Wesch Assistant Professor of Cultural Anthropology Kansas State University, with his class Digital Ethnography, released The Machine is Us/ing Us.
What has changed after one year? Do we still share the vision that Prof. Wesch brilliantly explicated with this video? And, after all, what is Web 2.0?


Tuesday, February 19, 2008


Not so long ago, I stumbled on this delightful XKCD strip about Python and my life changed forever since :-)
It was my first contact with XKCD, and of course I spent the next couple of hours devouring their comic strips! Absolutely wonderful!
Now, I'm wondering about Python... ;-)

Monday, February 18, 2008


Okay, I just decided to start learning another programming language.
Not for a new job. Not for any new project in particular. Just for the sake of it. (The sake of it!)
It's going to be Ruby... and I don't even know why! But I bet it will be an interesting new journey.
...Oh well, if Ruby sucks I can always change my mind later and switch to [insert a random language name here]!!!

A Coder's Code

What is a coder's code like?
Is it maybe like this:
(be faithful) ?
or like this:
(do (no evil)) ?