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.

This entry was posted in Demo, SWT. Bookmark the permalink.

13 Responses to Demo: Java2Script Google Talk in SWT

  1. I liked that web based google talk..
    really good interface.. 4 chat..
    need to improve little..

  2. Zhou Renjian says:

    Yes, a lot of works need to be done before it becomes an application or a service.

  3. Pingback: 雜七雜八的kewang部落格 ::PIXNET BLOG::

  4. sctronlinux says:

    The programme is so good. but UI is simple. Reorganizing the interface is better.

  5. Zhou Renjian says:

    O, the UI is Google Talk’s things. Just a complete copy.

  6. Pingback: 周仁建寻找生活 » Blog 存档 » IM(即时通讯)革命路

  7. Arun Christopher says:

    Oops, great work…., really great… keep rocking….

  8. Sharad says:

    I was trying to use the application but I don’t know what is wrong, either the application is too slow or is not working, i tried with Firefox 3.0.1, IE7 and Safari but none seem to be working

  9. Zhou Renjian says:

    @Sharad and others
    Now the Java2Script Gtalk demo should be working. Try it out.

  10. cris says:

    that shit , it takes many cpu ressources, i just tried it and my cpu went all freaky, review your program completely dude

  11. Zhou Renjian says:

    Thanks for pointing out CPU problem.
    From our tests, CPU is not a big problem. Would you like to provide more information about your environment, including CPU, memory and browser.

    We frequently review and modify our program for a better web instant messenging user experience.

  12. Maddy says:

    it does not open. it hands when it loads
    “”. Very bad.

  13. Zhou Renjian says:

    Please take another try. 🙂

Leave a Reply

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