Chapter 2. Getting Started with GWT

What Is GWT?

Before we get into building mobile apps let’s get to know GWT. GWT, or the Google Web Toolkit, is a set of tools, libraries and plugins. GWT was first released as an open source project by Google in 2006. They built it as a stable platform for their own web based applications that had to run across 100% of browsers, even the old broken ones.

At its core, GWT is a special compiler that can transform Java to JavaScript, along with a minimal runtime. It lets you write mostly standard Java code, then compile it to JavaScript for running in a web browser or other HTML environment. Once compiled there is no Java code left. The generated code runs entirely in the user’s web browser as JavaScript, no applets required. GWT has its own runtime consisting of a minimal set of standard Java APIs like List and String. These are implemented in JavaScript so that your code can call them even when converted. You can see the full list of emulated Java APIs at http://code.google.com/webtoolkit/doc/latest/RefJreEmulation.html.

GWT isn’t just a compiler though. It is also a set of cleverly designed compile steps and runtime libraries that handle browser differences. The compiler can generate different output for each browser, ensuring that the code runs properly no matter what browser the user has, even IE6! The compiler knows how to optimize object references, take advantage of JavaScript language tricks, and reduce memory usage. Much like a traditional ...

Get Building Mobile Applications with Java now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.