Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
At this point, your initial implementation of StockWatcher is complete. So far, you've been running StockWatcher in hosted mode. In hosted mode you can see the effect of your code changes immediately and use your IDE's debugging tools. After you compile StockWatcher, you can run and test it in web mode. When an application runs in web mode, it exists as pure JavaScript but does not require any browser plugins or the Java Virtual Machine (JVM).
In this section, you'll:
You'll also learn about deferred binding, GWT's mechanism for serving just the code required depending on browser or, optionally, other factors such as locale.
To compile the Java source code to JavaScript, you'll use the GWT compiler.
.In the Eclipse console you will see the output of the GWT compiler, e.g.
Compiling module com.google.gwt.sample.stockwatcher.StockWatcher
Compiling 5 permutations
Permutation compile succeeded
Linking into war
Link succeeded
Compilation succeeded -- 18.175s
Alternatively, you may compile from the hosted mode browser as described below.
You can compile the StockWatcher appliciation either from the hosted mode browser or directly from the command line.
To invoke the GWT compiler from the hosted mode browser:

Or to invoke the GWT compiler directly from the command line:
ant buildIf you run the GWT compiler from the command line, you can specify the style of the JavaScript, the level of logging detail, and override other default behaviors by modifying the StockWatcher/build.xml file.
After the application is compiled, a new browser window opens. This is not the hosted mode browser. It's the default browser for your machine. StockWatcher looks and behaves just as it did in hosted mode. The real difference is hidden under the covers. When you interact with StockWatcher now, it's executing JavaScript code in the browser, not Java bytecode in the JVM.
If you're running on a Mac, the default browser is Safari; on a PC, Firefox.
On Linux, in order to make your default browser open when you click Compile/Browse you'll need to first set the GWT_EXTERNAL_BROWSER environment variable to point to your browser executable for the IDE launch configuration or ant hosted.
At this point, you could deploy StockWatcher to a public web server simply by uploading the files in the output directory. This initial version does not need to communicate with the server in any way; therefore, it does not require anything special on the part of the web server. Any server that can serve up static web pages will do just fine.
Take a look at the files generated by the GWT compiler. In the output directory StockWatcher/war/stockwatcher, you see a set of files similar to this:
14A43CD7E24B0A0136C2B8B20D6DF3C0.cache.png 29F4EA1240F157649C12466F01F46F60.gwt.rpc 34BCFF35CB8FD43BCBFC447B883BCADC.cache.html 52BE5EB1FD9F0C2659714EE874E24999.cache.html 548CDF11D6FE9011F3447CA200D7FB7F.cache.png 667F52D77BB3D008A2A6A484569C3C35.cache.html 9DA92932034707C17CFF15F95086D53F.cache.png A7CD51F9E5A7DED5F85AD1D82BA67A8A.cache.png B8517E9C2E38AA39AB7C0051564224D3.cache.png CC9E2ADC408F47959407F6440C301B88.cache.html DF6EEF5BB835EE6FD9BBA5E092B0C429.cache.html clear.cache.gif gwt hosted.html stockwatcher.nocache.js
In addition to the static resources in StockWatcher/war (such as the HTML host page, style sheet, and images directory), notice the other file names contain GUIDs. These files contain the various JavaScript implementations of StockWatcher. GWT generates multiple implementations of your application, a unique permutation for each supported web browser.
At runtime, GWT uses a mechanism called deferred binding to load the correct permutation for the end user's browser. Deferred binding serves just the code the user needs and no more. What are the benefits of deferred binding? Because each permutation is tailored to work around the bugs and idiosyncrasies of its intended web browser, using deferred binding is
In addition browser detection, deferred binding can also generate customized versions of your application for any number of other variables. One very common example is internationalization. With deferred binding, GWT generates a separate implementation of the application for each language, so for example, an English speaker doesn't have to download the French text (and vice versa).
You can try this for yourself in the tutorial Internationalizing a GWT Application.
At this point you've tested StockWatcher both in hosted mode and in web mode. By now you should have a pretty good idea of how to develop a GWT application, which has only client-side functionality, from start to finish.
To build upon the initial implementation of StockWatcher and learn additional features of GWT, select from the following tutorials: