Thursday, October 9, 2008


GWT + maven2 + eclipse on 64 bit linux in 30 seconds

GWT is a toolkit for building world class web2.0 gui applications without the headache. Setting up an Eclipse dev environment on 64 bit fedora core (version 9) however required some extra steps. I heard that Google is working on a smoother 64 bit integration but until it's here you might find the list of required actions useful:

The basic installation

1. Get GWT
GWT comes in three flavours - one for win, one for mac and one for (32 bit) linux. Manual installation of gwt is not strictly reguired for maven + eclipse use but it's also convenient to have it around to be able to run your apps in hosted mode without maven.

2. Get 32 bit jdk
The default JDK in my fc 9 installation identified itself as "OpenJDK Runtime Environment (build 1.6.0-b09)" and if you try to start gwt Shell with it all you get is following error message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: ...gwt-linux-1.5.2/ .../gwt/gwt-linux-1.5.2/ wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)

The cure to this problem is to fetch and install a 32 bit java from sun.

3. Install some required 32 bit libraries:

If your see error like:

Exception in thread "main" java.lang.UnsatisfiedLinkError: .../gwt/gwt-linux-1.5.2/ cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(
at java.lang.ClassLoader.loadLibrary(
at java.lang.Runtime.load0(
at java.lang.System.load(
at org.eclipse.swt.internal.Library.loadLibrary(
at org.eclipse.swt.internal.gtk.OS.(
at org.eclipse.swt.internal.Converter.wcsToMbcs(
at org.eclipse.swt.internal.Converter.wcsToMbcs(
at org.eclipse.swt.widgets.Display.(
Could not find the main class: Program will exit.

you need to install 32 bit version of libXtst.
sudo yum install libXtst.i386

If you see error like

Exception in thread "main" java.lang.UnsatisfiedLinkError: .../ cannot open shared object file: No such file or directory

You need to install gtk2

sudo yum install gtk2.i386

If you see an error like

** Unable to load Mozilla for hosted mode **
java.lang.UnsatisfiedLinkError: .../gwt/gwt-linux-1.5.2/mozilla-1.7.12/ cannot open shared object file: No such file or directory

you need to install the 32 bit compat-libstdc++ library:
sudo yum install compat-libstdc++-33.i386

You are now ready for command line development of GWT apps. Just remember to set the path so that the 32 bit java is used to launch the GWT Shell.

Alternative way for maven users

1. Get 32 bit jdk

2. Install the required 32 bit libraries

3. Check out sample maven app that uses gwt-maven

svn co sample

Launch the sample application

cd sample
mvn gwt:gwt

Launching GTW Shell from eclipse

1. Import (or check out from scm) your project into eclipse
2. From Run menu select Run Configurations
3. Right click Java Application from left side of the screen and select new
4. Set as Main class
5. At Arguments tab enter the module name as program argument (in the sample it is com.totsp.sample.Application)
6. From tab JRE make sure that the 32 bit jre is used for the project
7. From tab Classpath click Advanced... select Add Folders and select the src/java folder from your project (ot the folder that contains the <package>/Module.gwt.xml file)
8. Click 'Apply' and 'Run'

Your GWT app is now running and you can enjoy features like nice fast dev cyckle edit->save->refresh, debugger etc.

Labels: , , ,