In short, a developer using the toolkit will be using the Java programming language before compiling, and then test the web application in the development mode using tools offered by the Google web toolkit.
This tutorial will focus on the use of the Google web toolkit in Ubuntu (Linux) and is primarily targeted at beginners.
Getting Started with Google Web Toolkit
You need to download the toolkit, which is available here: http://code.google.com/webtoolkit/download.html. Click the “Download SDK” button.
It will then be downloaded to the Ubuntu download folder. Right click on the zip file, and then click “Extract here.” Copy the folder (e.g gwt-2.0.4) to your Ubuntu desktop.
The best way to get started with the Google web toolkit is to create a web application using it. For the sake of simplicity, let's use the test web application illustrated here: http://code.google.com/webtoolkit/gettingstarted.html
Note that the procedure is not quite specific, and you need to know all the steps in detail, including troubleshooting and terminal commands. So let's illustrate that in this tutorial completely.
Since your Google web toolkit is now located in your Ubuntu Desktop, open the terminal (Applications ==> Accessories ==> Terminal). Let's create a web application and name it MyWebApp
The commands are as follows:
codex-m@codex-m-desktop:~$ cd Desktop
This app goes to the Ubuntu Desktop, and then changes the directory to gwt-2.0.4. The CHMOD u+x actually makes the webAppCreator executable; this is necessary to create the application.
If there is no problem, several files and directories will be created by the Google web toolkit.
Installation of Apache Ant as a Build Tool to Compile Java Code
Now that it is completely installed, let's run the Google web toolkit development mode using Ant. Open the terminal, and then type the commands below (assuming you do not change your Google web toolkit directory and it is still found on the Desktop):
codex-m@codex-m-desktop:~$ cd Desktop
However, when you execute the ant devmode command, you might encounter an error such as the one below:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
This is because the Openjdk-6-jdk (Open Java Development Kit) is still not installed and configured to work with the Google web toolkit.
Open the Java Development Kit for Google Web Tool Kit
To install the required Java development toolkit:
1. Go to the Synaptic manager, and in the quick search, type java-6-openjdk.
2. You need to click: openjdk-6-jdk
3. Continue with the installation until it is successfully completed.
4. Go to Applications ==> Accessories ==> Search for files...
5. Under “Name contains:” type tools.jar. You need to know the updated JDK path of this file in your Ubuntu file system.
You should see results like this: usr/lib/jvm/java-6-openjdk/lib
This is the folder in your Ubuntu file system that contains the tools.jar file using the Open Java Development Kit. This means you have successfully installed openjdk.
When you look at the error in the previous section, it required pointing the JAVA_HOME to openjdk for the build to succeed.
You need to edit the bash.bashrc file in the Ubuntu etc directory. To do this, open up the terminal, and then type the following commands:
codex-m@codex-m-desktop:~$ sudo -s -H
Scroll down to the bottom of the file, and then add the following code:
If the path that contains tools.jar (in the file search result previously) is: usr/lib/jvm/java-6-openjdk/lib
You should set JAVA_HOME to /usr/lib/jvm/java-6-openjdk
To confirm your new JAVA_HOME, enter this in terminal:
root@codex-m-desktop:/etc# echo $JAVA_HOME
It will check the new location of Java Home, so the result should be:
root@codex-m-desktop:/etc# echo $PATH
blog comments powered by Disqus