Category Archives: Demo

Demo: Java2Script Google Talk in SWT


In March, I wrote “Java2Script version of Google Talk”. It was a very simple SWT application that talks to using Jabber XMPP protocol by Smack library.

About 3 months later, I rewrote the whole Java2Script version of Google Talk. In this time, I still used Smack library. But I used Instantiations’ Windows Builder Pro to help me to design the whole interface. And this time, it copied all existed UI from the desktop version of Google Talk, including every dialogs, menus or layouts. It looks almost exactly the same of Google Talk.

Here is the demo addres:

P.S. Other available web IM services provided by this Java2Script technologies:

Here are some screenshots:

Click for Large Screenshot: Google Talk Client’s JavaScript Copy


It is just trying to re-implement all the features of Google Talk except the voice talk. And all dialogs or layouts are copied from Google Talk, as I thought that Google Talk is excellent.


Jabber Server ( –> XMPP –> Tomcat Server (Smack) –> mod_jk Connector –> Apache HTTP Server –> Browser Client


Java2Script’ Simple RPC and Simple Pipe were used in the Java2Script Google Talk. Simple RPC serializes requests from browser to server, and server will parse them and send out related XMPP requests. All packets received from Jabber server are piped through Simple Pipe to the browser. The Simple Pipe just serializes XMPP packets into SimpleSerializable instances, and sends out through the comet HTTP connection.

That is to say, Simple RPC is OutputStream and Simple Pipe is InputStream in Java’s terms. And all data are serialized or deserialized by SimpleSerializable.


JavaScript and DOM manipulation is very slow actually. And loading bundles of *.js from server to browser also requires a very long waiting. In order to improve the performances, lazy loading technologies are applied.

First, lazy loading those *.js related to the UI until the UI is required. For example, chatting dialog related classes’ *.js only be loaded when user open a chatting dialog or a message is received. This principles are also applied to settings dialogs, inviting friends dialogs and others. To lazy loading *.js, AClass or ASWTClass is introduced in Java2Script. It will load classes only when needed. The usage of A/SWT/Class is as following:

ASWTClass.shellLoad ("org.java2script.....", new ARunnable () {
public void run() {
// begin to later action.

Second, some part of codes are executed lazily. For example, create menus may require a lot of CPU times for browser. So only before the menus are to be shown do the menus are being created. In such a way, only what you see on the UI is created. Or they won’t be created by default.

Third, virtual list is used to avoid large friends list updating. For example, if there are more than 200 friends on one’s Google Talk friends list and concrete SWT widgets are created according to each friends, there will be 200 widgets being created. And it will freeze the whole browser UI. And when the dialogs are resized, re-layout these hundreds of widgets may also freeze browser. To avoid such freezing, virtual list is introduced. The virtual list is that only visible list item are created. Those invisible items are never created. In such a way, 500+ friends are supported.

Posted in Demo, SWT | 13 Comments