Saturday, July 25, 2009

Google Web Toolkit

Google Web Toolkit requires Java 1.5. Running GWT with ANT using Java 1.6 results in the message "You must use a Java 1.5 runtime to use GWT Hosted Mode on Mac OS X." So the first command will set up the Macintosh to use Java 1.5 then the following commands run the Mail Client sample.

[greg:~] export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home"
[greg:~] cd dev/bin/gwt-mac-1.7.0
[greg:gwt-mac-1.7.0] cd samples/mail
[greg:mail] ant hosted

To create a new application, run the webAppCreator script.
[greg:src] ../webAppCreator -out MyApplication com.mycompany.MyApplication
[greg:src] ls
MyApplication
[greg:src] cd myapplication
[greg:myapplication] ant hosted

The code being run is a gwt Remote Procedure Call and it follows here:
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
    GreetingService {

  public String greetServer(String input) {
    String serverInfo = getServletContext().getServerInfo();
    String userAgent = getThreadLocalRequest().getHeader("User-Agent");
    return "Hello, " + input + "!<br><br>I am running " + serverInfo
        + ".<br><br>It looks like you are using:<br>" + userAgent;
  }
}

Cool stuff.

Wind up by returning your Java version to the most current setting.
export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"