GWT: Running a completed project
Hosted mode and the GWT shell
When you run ApplicationCreator, GWT creates some shortcut scripts for invoking GWTShell and GWTCompiler with the project. For this example, we'll first execute GWTShell using the [PROJECT_HOME]/Calculator-shell script (it will have a platform-dependent extension). The next step is to ensure that the environment is configured as it needs to be to support GWT and the project itself, and then invoke Calculator-shell. It should successfully invoke the example in the shell as shown in figure 1.
Figure 1 The GWT shell and hosted mode browser running CalculatorWidget
The background window in figure 1 is the GWT shell, and the foreground is the hosted mode browser running CalculatorWidget. The GWT shell includes a logging console where any problems will be displayed. This includes exceptions, which are passed up the call stack. The shell also includes buttons for manipulating the log and launching the hosted mode browser.
Can the GWT shell browser be specified?
When you launch the GWT shell, you'll notice that the hosted mode browser is the system browser for the platform you are using. This means Internet Explorer on Windows, Safari on Mac, and Mozilla Firefox on Linux. The hosted mode browser is actually based on SWT browser components, so it is not currently possible to specify or configure which browser is used when running the shell. (This will change in the near future with out-of-process hosted mode, which will allow you to use any supported browser on a platform.)
To connect to the GWT shell for the purposes of debugging, you can use the Java Platform Debugger Architecture (JPDA), which is built into most JVM implementations, and your favorite IDE. By invoking com.google.gwt.dev.GWTShell with the following command-line options, you can force the GWT shell to delay startup until a debugger has connected:
-Xdebug -Xnoagent -Djava.compiler=NONE
Using this technique, you can run the shell outside of your IDE, and then connect to it with Eclipse, or NetBeans, or such, at localhost:8888. Once this connection is made, the socket listener resets to the HTTP listener from the shell and you can continue your step-through debugging as you normally would.
Web mode and the GWT compiler
Figure 2 CalculatorWidget running in web mode, using Firefox on a Mac, after clicking the Compile/Browse button in the GWT shell
This article is excerpted from Chapter 1 of GWT in Practice, by Robert Cooper and Charlie Collins, and published in May 2008 by Manning Publications.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)