Developing Ajax Applications With OS/2 & The Google Web Toolkit (GWT).


  Metztli Information Technology makes no implicit and/or explicit guarantees that you will achieve success performing this procedure on your OS/2 system. If you decide to follow these instructions, please do not hold Metztli I.T. responsible if you experience problems --including loss of use of your machine-- we are about to start a light duty hacking exercise and things may go wrong.  You may even make a backup of your system BEFORE you proceed if you are an OS/2 user with not enough technical proficiency and do not usually perform these technical procedures. 

On the other hand, if there is anything that you do not understand (after reading with care the instructions) and/or that does not work as stated (after reviewing the assumptions that I make and modifying accordingly your OS/2 environment), please let me know.  I will try to help you solve your issue --as my time allows, of course. 

This excerpt forms part of a larger work in progress. Subsequently, and if you are willing to put up with me, we will take on the high level development of an application described at IBM's Developer Works Accordingly this is only the first of a two part series designed to show how to use the Google Web Toolkit to develop AJAX applications entirely on the OS/2 platform.


On the second part of the series, we will bundle a *.war file into an Jetty Java application server so that when the user points a browser to the public (html) interface of the *war file (that you may run in a Java application server like WebSphere Application Server Community Edition, as well) and subsequently enters a zip code, the wheather will be displayed for the pertinent (zip code) area using the Yahoo! API.  Hence, providing a preview of the result, the goal in our final work will be as shown in this snapshot.

I have made available for download an self-extracting and a regular *.zip file with a bundled EMX environment and the needed utilities to work with the Google Web Toolkit (GWT) --since it is the Penguin that most has helped the OS/2 to survive up to now. If you do not have a decompresor of *.zip files (those that you may have already downloaded with the extension *.zip), download PkWare PKZIP V2.50 for OS/2. 

After extracting the executable to a temporary directory,  place the pkzip.exe in  your OS/2 PATH directory ( I recommend under \OS2 to execute from anywhere you happen to be in your directory structure). Once the pkzip.exe utility is in your PATH environment variable, you may decompress *.zip files as follows:

pkzip /extr /dir FileWithZipExtension.zip


Where of course, you substitute the dummy file name FileWithZipExtension with that of your actual zipped file.



If you already have the emx environment, please observe the assumptions that I make and that are described below --do not disregard them if you want to avoid some extra frustration. Otherwise, download either of the self extracting or the   regularly zipped alternative

Once downloaded, place either in your OS/2 root drive and for the self-extracting file make sure to extract directories by typing at a command prompt:

emxMetztli.exe -d

or

pkzip /extr /dir emxMetztli.zip


The command will create a directory under your root drive letter called emx and it will extract a couple of files into your X:\OS2 directory named myEMX.cmd, myGoogle.cmd, and myAnt.cmd. Open each *.cmd file in your TEXT editor (not in a word processor) and replace the default S: root drive letter to reflect your specific directory structure.

THE FUNCTION OF THE BUNDLED FILES:

myEMX.cmd
 will create an Unix/Linux environment needed by the Google Web Toolkit version that we will use.

myGoogle.cmd sets CLASSPATH and current directory environments as well as the long command to start GWT's long java create command under OS/2.  

myAnt.cmd (we will not use it until the second part of the excercise)
  sets environment variables for the Java build utility from the Apache foundation (we will be using the current version apache-ant-1.7.0-bin.tar.gz  at Apache-ant-1.7.0-bin.tar.gz as of 01-04-2007)

IMPORTANT ASSUMPTIONS I MAKE AS A PRECONDITION FOR A SUCCESSFUL PROJECT:

I will be assuming that you have the Golden Code Development (GCD) native OS/2 implementation of Java in your PATH OS/2 environment variable (I used the version 1.4.1_7).  Further, I will assume that your OS/2 CLASSPATH environment variable is NOT SET. Please note that GCD did not recommend setting a CLASSPATH variable at all in their literature describing the appropriate manner to use their product of unparalled quality in the OS/2 realm.

Consequently, the *cmd files that I will describe will be the first to set their CLASSPATH environment for the procedure involved.  If you have an already set CLASSPATH environment, you have the option of remming it out in your OS/2 CONFIG.SYS by inserting a REM statement in front of such set statement like:

REM SET CLASSSPATH=< your pertinent settings >

proceed to save your CONFIG.SYS and rebooting your OS/2 machine.

Alternatively, if you do not want to "mess" with your CONFIG.SYS, OS/2 (Warp 31 and above) allows you to dynamically set your CLASSPATH to a null value --but only for the sesion(s) where you do open an OS/2 command prompt and type:

SET CLASSPATH=

If your were to have subsequent windowed OS/2 command line sessions inherit the null CLASSPATH variable and others that you set in the same windowed session, you could type from the initial (parent) windowed OS/2 command prompt:

start

and the next command prompt window will inherit the null CLASSPATH statement plus others that you might set with the *.cmd files that I provide (see your OS/2 documentation for more information).

I will also be assuming that your PATH statement ENDS WITH A SEMICOLON (;) This is very important as the *cmd files that I will be referencing WILL NOT perform appropriately if your OS/2 PATH environment variable is not terminated with a semicolon (;)

Please modify your OS/2 PATH statement if the immediately elaborated condition is not met.  Save your changes to your CONFIG.SYS and reboot your OS/2 system.  Although you could modify the *.cmd files that I will describe if your PATH statement is not ending in a semicolon (;), let us try to keep it simple.

UNIX/LINUX UTILITIES THAT YOU WILL NEED (AT LEAST):

You will need at the very least the following Unix/Linux utilities ported to OS/2: tar.exe, gzip.exe, chmod.exe, dirname.exe, and shell-specific sh.exe and ksh.exe in addition to the Ant Java build utility.  As explained above, those are provided in an "as is" basis in the bundled EMX environment but below I will provide the pertinent links where they can be downloaded:

tar.exe, gzip.exe, and pkos2250.exe

chmod.exe and gnufutil.zip

emxrt.exe and others to accomplish the runtime environment


and apache-ant-1.7.0-bin.tar.gz will be needed for the IBM Developer Works project.

REPLACE THE DEFAULT S: DRIVE IN THE *.CMDs WITH YOUR OWN

However you obtained your EMX environment, it is time to set the important configuration variables in the three *.cmd files.

If you downloaded the EMX bundle that I made available, please look under the OS2 directory of your current root drive.  You will find three files: myEMX.cmd, myGoogle.cmd, and myAnt.cmd.

Open myEMX.cmd in your text editor (NOT in a word processor unless you know how to save in text format) and read the disclosure.  If you agree with it,  proceed to edit the file by replacing the default S: drive with your specific root  drive.  Notice that I recommended to extract to your root drive everything BUT if you are using a non default OS/2 directory structure (for example, having ECS instead of OS2 in your path environment) you should make appropriate modifications to that foreign structure in the file myEMX.cmd.

After you are satisfied with the modifications, save your changes and once again please verify that your OS/2 PATH environment variable ends with a semicolon in your CONFIG.SYS.  If it does not, edit your CONFIG.SYS and add the semicolon to the end of the PATH environment variable:

See sample OS/2 PATH environment:

SET PATH=S:\OS2;S:\OS2\SYSTEM;

Now it is time to test your emx environment.  Open an OS/2 command prompt window and type:

myEMX.cmd



you should see the enviroment variables contained inside the file being set by OS/2 (and scrolling by your screen window).

The prompts below assume an OS/2 directory S: consequently the OS/2 window command prompt is [S:\] in this example:
Thus, enter at the command prompt:

[S:\]emxrev



you should see:

EMX : revision = 61
EMXIO : revision = 60
EMXLIBC : revision = 63
EMXLIBCM : revision = 64
EMXLIBCS : revision = 64
EMXWRAP : revision = 60

Now,  proceed to enter your Unix/Linux public domain Korn shell (pdKsh) by typing:
[S:\]ksh

and the pdKsh will output the very first prompt to wait for your input:
[1]/:

Think of a temporary directory, for instance \GWT and think in what drive you have enough space for the extraction of the file that extracted is about 50MB.  Once you have selected a suitable drive proceed to make your gwt directory:
[1]/: mkdir --verbose gwt
mkdir: created directory `gwt'
[2]/:

Download the current (as of 01-06-2007) Google Web Toolkit for the Linux operating system.  Point your browser at: gwt-linux-1.3.1 gwt-linux-1.3.1.tar.gz and follow the download by the extraction of the compressed files. Use the command:
[2]/: tar -xvpzPf gwt/gwt-linux-1.3.1.tar.gz

You will see a lot of files (being extracted) scrolling by your window.  Now, we will unhide some files in the extracted directory.  For some reason in gzipped tar files for Unix/Linux, there remain some files with the hidden(h) and system(s) attribute.  Hence, we proceed to uncover recursively the newly created gwt-linux-1.3.1 directory searching for files with hidden attributes to make them visible.  We enter the command:
[3]/: chmod -R u-h gwt-linux-1.3.1
[4]/:

And then we search for those with system attributes and remove that property recusively ( -R switch ):
[4]/: chmod -R u-s gwt-linux-1.3.1
[5]/:

One of the command files that we will need for our first Google Web Toolkit application that we just "uncovered" by removing the hidden and system attributes is the file applicationCreator.  We can verify its existence whith the Unix command "ls" that is the equivalent of the OS/2 dir:
[5]/: ls gwt-linux-1.3.1/app*
gwt-linux-1.3.1/applicationCreator

We proceed to edit the contents of the file; specifically we edit the CLASSPATH environment variable that is not needed (and causes problems) because we set it with the OS/2 command extracted in your OS2 directory if you downloaded either emxMetztli.exe
or
emxMetztli.zip

Change to your newly created directory and type:
[6]/: cd gwt-linux-1.3.1
[7]/gwt-linux-1.3.1: epm applicationCreator


Observe (highlighted) the code that we will edit by removing it and saving our changes (note that it is the CLASSPATH related information --that works under Linux-- but somehow causes problems under OS/2 if left in applicationCreator):

Finally we are all ready to create our very first Google Web Toolkit application under the OS/2 environment.

Accordingly, we will now set the PATH and CLASSPATH environment variables to be able to call GWT applicationCreator from anywhere we find ourselves in our file system directory structure.  That is achieved with the *.cmd file myGoogle.cmd.  Notwithstanding, before we call that file from the command line we must exit our Korn Shell environment.  The reason is that setting any OS/2 variables from within the Unix environment do not take effect.  Hence,  please exit your Korn Shell environment since you have already verified that your EMX environment is functional.
[8]/: exit
[S:\]

Proceed to type the name of the file containing your GWT specific OS/2 environment variables:

[S:\]myGoogle.cmd



After the relevant environment variables scroll by your OS/2 window, enter your Unix/Linux environment again by entering at your prompt:
[S:\]ksh.exe
[9]/:

Let us make a working directory to keep things  a little organized.  We will name it gwt-FirstApp and change directory to that location:
[9]/: mkdir --verbose gwt-FirstApp
mkdir: created directory `gwt-FirstApp'
[10]/: cd gwt-FirstApp
[11]/gwt-FirstApp:

Well, let us create our application according to the structure the Google documentation suggests:
[11]/gwt-FirstApp: applicationCreator com.metztli.client.MyOS2World
Created directory S:\gwt-FirstApp\src
Created directory S:\gwt-FirstApp\src\com\metztli
Created directory S:\gwt-FirstApp\src\com\metztli\client
Created directory S:\gwt-FirstApp\src\com\metztli\public
Created file S:\gwt-FirstApp\src\com\metztli\MyOS2World.gwt.xml
Created file S:\gwt-FirstApp\src\com\metztli\public\MyOS2World.html
Created file S:\gwt-FirstApp\src\com\metztli\client\MyOS2World.java
Created file S:\gwt-FirstApp\MyOS2World-shell
Created file S:\gwt-FirstApp\MyOS2World-compile
[12]/gwt-FirstApp:

Notice the last two files that GWT's applicationCreator echoed to the screen: MyOS2World-shell and MyOS2World-compile.  Of those files an OS/2er is not able to use the first because it requires SWT; consequently, we will focus on editing the other file: MyOS2World-compile.

Open the file in your text editor.  In the example, I use EPM:
[12]/gwt-FirstApp: epm MyOS2World-compile
[13]/gwt-FirstApp:

Again we remove the highlighted CLASSPATH (-cp) specific Java directive since we priorly set the OS/2 equivalent with myGoogle.cmd file, do you recall?  Save your changes to the file and get ready to compile your very first GWT application by entering the following command:

[13]/gwt-FirstApp:  MyOS2World-compile
Output will be written into .\www\com.metztli.MyOS2World
Copying all files found on public path
Compilation succeeded
[14]/gwt-FirstApp:

Needless to explain, the Java to AJAX compilation succeeded with our GCD Java under our OS/2 environment.  To look at the output, let us open our browser with the newly created html file: www/com.metztli.MyOS2World/MyOS2World.html

And simply for reference, this is a list of the files that we have just created:
[15]/gwt-FirstApp: ls www
com.metztli.MyOS2World/

[16]/gwt-FirstApp: ls www/com.metztli.MyOS2World
00E46BF9EAB2FB42A0C30F32D1904EA0.cache.html
00E46BF9EAB2FB42A0C30F32D1904EA0.cache.xml
49F0BE7626CCE1DEF5813E1F0B1C4879.cache.html
49F0BE7626CCE1DEF5813E1F0B1C4879.cache.xml
C43AC3A2089CC72239ADBC3AFD76BEEE.cache.html
C43AC3A2089CC72239ADBC3AFD76BEEE.cache.xml
D2FB3776BFE84E3D3FCE2E1B3AFCF2E1.cache.html
D2FB3776BFE84E3D3FCE2E1B3AFCF2E1.cache.xml
MyOS2World.html
com.metztli.MyOS2World.nocache.html
gwt.js
history.html
tree_closed.gif
tree_open.gif
tree_white.gif