• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

GWT installation and creating a GWT Project

March 29, 2009 //  by JavaBeat//  Leave a Comment

Installing GWT

To develop programs using the GWT we need to first download it from here : GWT download.
Once you have it installed the next step would be to update the PATH environmental variable. For example if you have installed GWT in you C: drive as C:gwt-windows-1.5.3 then append this path to the end of the PATH variable. Once this is done you are ready to create GWT projects.

[Note: You need JDK 1.5 or above to develop GWT projects. You also need an IDE to develop the GWT projects. We will use Eclipse IDE in this tutorial]

Creating an Eclipse GWT project

Once the installation part is over we can now jump onto creating a new GWT project. Lets create a project which shows the temprature of cities.

  • Open windows command prompt and navigate to the GWT installation directory. For e.g: C:gwt-windows-1.5.3>
  • Create a directory by using the following command in current path:
    mkdir TempratureWatch
  • Change your current working directory to the directory we just created by using the following command:
    cd TempratureWatch

    After executing this command you should be at this location :

    C:gwt-windows-1.5.3TempratureWatch>
  • Next type the following command in the current path:
    projectCreator -eclipse TempratureWatch -out TempratureWatch
    

    After executing this command, a directory by the name TempratureWatch is created. Inside the directoty we see the following directory and files :

    • src – directory for storing the project source code
    • test – directory for storing unit testcase
    • .classpath – file used by Eclipse
    • .project – file used by Eclipse
  • Next execute the following command :

    applicationCreator -eclipse TempratureWatch -out TempratureWatch com.google.gwt.sample.tempraturewatch.client.TempratureWatch
    

    This command creates a package structure as specified in the command line and creates a java class called TempratureWatch.java which would be the application’s entry point. The package structure chosen is as per GWT naming conventions. The entry point class must always be inside the client directory. The command also create an XML document called TempratureWatch.gwt at this location com.google.gwt.sample.tempraturewatch. This file will hold configuration settings for the GWT application.

Importing the project to Eclipse

Once you have the project directories created by using the commands explained in the last section the next step would be import the project to Eclipse. This can be done by using the following steps :

  • Start Eclipse, then select File -> Import
  • Select the project root directory by selecting: General -> Existing Projects into Workspace
  • Select directory of the project. In our example we should choose: C:gwt-windows-1.5.3TempratureWatch
  • Click Finish

Once done, you should be able to see the imported project in the Eclipse workspace. To run the application in hosted mode select the project and select the Run option under the Run menu. If the program starts successfully then you should be able to see a sample page which is created by default when you create a GWT project.

Difference between Hosted mode and Web mode

There are two possible ways by which we can execute our GWT project:

  • Hosted mode
  • Web mode

The way we started our application in the last section was the Hosted mode execution. In hosted mode the application is converted to bytecode and executed by the JVM (very much like java). This allows us to take advantage of the Java language API. In addition to this the hosted mode also allows us to debug application easily.

In Web mode the code is converted to JavaScript and executed by the browser.

Category: GWTTag: GWT

Previous Post: « XML Schema Elements – Part2
Next Post: GWT user interface components »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact