Desktop Java

Setting up development environment for GWT

Introduction

This is part of series intended to develop cross platform mobile applications in Java. In this blog post we will see what GWT is and set up the development environment for GWT.

GWT is an open source development toolkit for developing complex browser based Ajax applications. Using GWT you can develop Rich Internet Applications(RIA) in Java which is then compiled into JavaScript and is cross browser compliant.

Some of the advantages of developing web applications in GWT are:

Since GWT apps can be developed in Java, you can enjoy all the advantages of developing in Java like auto-complete,Debugging, refactoring, code reuse, polymorphism, over riding, over loading. And Java has large set of tools for development like Eclipse, NetBeans,JUnit and Maven etc which you can use for developing Rich Internet Applications(RIA).

Maintaining large JavaScript projects is not easier when compared to Java projects. But you need JavaScript to run Rich Internet Applications in browser. GWT combines both the advantages. You develop the applications in Java and then they are compiled into JavaScript, so you are having best of both.

GWT is almost similar to AWT and Swing packages in Java and so has a low learning curve for Java Developers.

Supporting several browsers in the market is a difficult tasks. Each browser creates it own set of problems. GWT solves this problem by creating optimized JavaScript code for each browser specifically addressing the issues with that browser. So you can support almost all the major browsers including Android , iPad and iPhone based browsers without worrying about quirks for each browser.

Developing UI’s in Java is difficult task compared to other aspects of Java programming. GWT solves it by providing several UI widgets and also you can extend the existing widgets and create your own custom widgets if you wish to.

Some of the limitations of GWT are:

Since the java code is compiled into JavaScript which runs on the browsers, the JavaScript needs to be enabled on the browsers. The applications will not work if the JavaScript is not enabled on the browser.

If you have specialist UI designers who can create HTML pages, this will not work. You may have to implement what ever Designer created again in GWT.

Web Pages created by GWT cannot be indexed by search engines since these applications are generated dynamically.

I think except the second drawback in the list, others don’t matter much. It is difficult to provide a rich internet application just in HTML. You will need JavaScript to create rich internet applications. Some apps provide a limited version of apps which work if JavaScript is disabled but majority of apps require JavaScript , so you are not the one there. And there is no reason why large number of users will disable JavaScript on their browsers.

And there is a work around for indexing by search engines. The index page can be created in html, and the remaining pages can be created in GWT. GWT provides an option to define index page in html format. So the index page can still be indexed by search engines and the other pages are mostly dynamically created data, so they don’t need to come up in the search unless you they are some kind of content management systems(CMS).

Like the case with all the frameworks, GWT doesn’t solve all the issues, but it surely makes the java developers more productive developing the web applications, provides cross browser support and works perfectly for complex enterprise web applications.

GWT Development Environment Setup

We will start setting up the development environment for GWT applications.

Java

Since you will developing the applications in Java before they are compiled into JavaScript, you need to set up Java development environment.

Once Java environment is set up, let us configure the environment for GWT.

GWT SDK

Download the latest version of GWT SDK from the GWT project site. http://www.gwtproject.org/download.html

gwt_112

 
Go to the above link and click on ‘Download GWT SDK’ highlighted in the above screen. Then unzip the downloaded GWT SDK to your preferred location on your hard disk and it will look similar to the below screen shot.

1017

 
You need to install the eclipse plug-in for GWT to develop GWT applications on eclipse easily. To install GWT eclipse plug-in, launch eclipse, go to Help –> Eclipse Marketplace.

1113

 
Search for GWT in the eclipse market place.

1222

 
Find out ‘Google Plugin for Eclipse’ and the version number should match the version of the eclipse you are using. If you are using Eclipse Kepler(eclipse 4.3), you need to look for ‘Google Plugin for Eclipse 4.3) and click on ‘Install’.

1243

 
Accept the license and click on ‘Next’ to continue installation.

1272

 
It takes some time to download and install the plug-in.

1293

 
While installing you will get a security warning. Just click on ‘Ok’ to continue the installation.

1303

 
Restart the eclipse after the installation of plug-in is completed. After restarting the eclipse, you will see the GWT plug-in added to the eclipse tool bar.

13113

 
And we need to install extensions to the browser you are planning to use for running the GWT app in development mode. We will see later what the development mode is, but for now let us install the plugins for the browser to complete our set up of the development environment. If you launch the app in Dev mode without installing the plug-in, the browser will display a message similar to below.

In Internet Explorer:

14413

On Chrome:

14713

 
When you click on Download, On Chrome, you will be redirected to the Chrome extensions page from where you can install the GWT Developer plug-in.

1464

Click on ‘FREE’ button to install the plug-in on Chrome browser.

On IE, clicking on ‘Download’ button will download a ‘GWTDevPluginSetup.exe’ set up and launching it will install the GWT developer plug-in for IE.

Restart the browsers after the GWT developer plug-in is installed.

Unfortunately the latest versions of Mozilla Firefox doesn’t support the GWT Developer Plugin. So you can’t work in Development mode on latest version of Firefox, but GWT already provides a super dev mode which doesn’t require installing any plug-in during development. So you can use Firefox in super dev mode during development mode.

Conclusion

We completed setting up the required development environment for developing applications in GWT. We can start creating GWT applications !!

Reference: Setting up development environment for GWT from our JCG partner Venkata Kiran at the Coding square blog.

Venkata Kiran

Kiran is a product developer working in medical domain. He worked on creating scalable java batch applications and is currently working on developing cross platform mobile applications. His current interests include automated testing of mobile applications.
Subscribe
Notify of
guest

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

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Ajan
Ajan
9 years ago

Mate… Why do you refer to Developer Mode Plugin when it’s almost depreciated? Super Developer Mode is makes developer much more productive!

Kiran
Kiran
9 years ago
Reply to  Ajan

Yes, Developer Mode plugin is almost depreciated. But it is still in use. Super Dev Mode is more productive also. But I didn’t want to pretend Dev Mode is already dead. It is a option still available and so want it to be there. I will cover Super Dev Mode later in the series, so you wont miss it:)

Msx
Msx
5 years ago

Don’t follow this. It’s completely outdated. You should follow GWT 2.8 approach. With IntelliJ zero configuration. Just use it. SuperDevMode works out of the box. You don’t need any plugin. Also for Eclipse. This manual is like 5 years old.

Back to top button