The Google Web Toolkit™ software development framework, or GWT, is a great open source SDK that lets you build web applications using the Oracle® Java™ language. Though it was intended for web-based applications loaded in a web browser, it can also be used to create native webOS applications.
What is GWT?
The first thing you might ask is why you might want to use GWT? There are lots of reasons. You might be a Java developer who prefers using a statically-typed language. You might be a web designer working with Java developers on your team. You might have existing Java code that you would like to reuse. Or maybe you just want to try something new. Whatever your reason, Google has a huge collection of resources to help you get started.
Building for the desktop browser
To get started, first run through the Get Started with the GWT SDK tutorial to make sure you have the GWT SDK downloaded and set up correctly. This will take less than 5 minutes.
Now run through the Google’s excellent full Getting Started tutorial. This should take less than an hour. In this tutorial you will make a simple stock watching app that has a full GUI, customized CSS, event processing, and field validation. Once you are done, you will have a GWT app running in your browser, like this:
Now you are ready to turn the GWT app into a webOS app. First, download PhoneGap as described here, then copy the phonegap-palm directory to a new location. We will copy all of the GWT output into the new phonegap-palm/framework/www/ directory.
This is the actual compiled application code and resources. GWT uses these long file names to ensure that all code is cached properly in the web browser when the app is loaded over the web. For our purposes we don’t care, since our app will be local. We just want to copy the entire contents of the war directory (except for WEB-INF) over to the phonegap-palm/framework/www directory.
GWT created the
StockWatcher.html page as the start page. webOS apps need an
index.html file to start, so rename
index.html. Now edit the
index.html to add the following code just inside the
Now add an event handler to the body tag to call
onLoad() when the app launches.
With these two change you can now build the webOS app. Just cd to the phonegap-palm directory and run ‘make’. This will generate an
.ipk file and run it in the emulator (make sure you already have the emulator started). If all went well it will look like this: