Author Archives: Zhou Renjian

Moving Blog to

As a matter of spam comments over (over 20 spam comments per day), the Java2Script blog is moving to , which is powered with WordPress’ Akismet plugin.

Even though former blog on was installed with Akismet plugin, Sourceforge limits its server from connecting to WordPress Akismet servers, which results in being unable to activate Akismet. After about-5-day-away, about 200 spam comments were piled up there. So the blog was moved.

Posted in Akismet, Wordpress | Leave a comment

Rewriting Java2Script’s GTalk

Here is an early screenshot:

Java2Script's GTalk

BTW: Window Builder Pro was used to design the above UI

For more updated information, please visit

Posted in Screenshot, SWT, WindowBuilder Pro | Leave a comment

Java2Script on Safari 3 Beta

As Safari 3 Beta was published, I just tested it on a Java2Script demo. Here is the screenshot:

Java2Script LZ77JS Compressor

Posted in Screenshot, Simple RPC | Leave a comment

Now Java2Script Supports Eclipse 3.3 M7

Follow instructions of “setup Java2Script environment from Subversion repository“, and checkout branches 3.3 from

Hope to hear your feedbacks.

Posted in Java2Script News | Leave a comment

Instantiations Donated WindowBuilder Pro to Java2Script for Development

Instantiations is giving back to the community by donating its products for use by developers of Open Source projects. For more information, please visit

Java2Script is mainly focusing on converting SWT desktop applications. And WindowBuilder Pro is sure a professional GUI designer to help developers building SWT desktop applications. As from earlier trials ( ), I found that SWT Designer is a great tool to help designing SWT applications. In order to improve our development efficiencies, I decided to apply for a copy of WindowBuilder Pro instead of limited trial versions. And Eric Clayberg of Instantiations is very kind to give a quick reply and is very generous to donate WindowBuilder Pro to Java2Script team.

Thanks Instantiations Inc. I think WindowBuilder Pro will help us working more efficiently and improving Java2Script plugin to a higher quality level.

Posted in Java2Script News, SWT, WindowBuilder Pro | Leave a comment

Java2Script 1.0.0 M5 Released

The long waited 1.0.0 M5 Release (Once supposed to be 1.0.0 Release Candidate) finally came.
To download and install Java2Script M5, please check
Zhou Renjian
1.0.0 M5 (March 16, 2007)
New and Noteworthy
Java2Script Core
1. Use Apache Harmony JRE sources instead.
2. Improved ClassLoader now supports multiple threads loading from multiple sites.
3. Lots of ClassLoader bugs are fixed to make sure *.js or *.css are correctly loaded or applied.
4. ClassLoader’s class loading is notified in a half-transparent messagebar.
5. Library *.js can be loaded from Firefox Add-on.
6. Java2Script inner console’s color is now black on white.
7. Java2Script related projects can be created by wizards.
8. Java2Script compiler is refactored a little.
9. More *.js optimized configuration for Apache HTTPD server, including gzip encoding.
Java2Script SWT
1. Window manager is introduced.
2. Shell’s maximizing and minimizing are improved.
3. Increasing or decreasing font size in Firefox is supported.
4. Widgets are improved.
5. SWT lazy loading is built inside.
Java2Script AJAX
1. Simple RPC protocol is modified
2. Simple RPC now supports Cross Site Script.
Java2Script Example
1. Java2Script version of Google Talk ( )


If you download or install Java2Script 1.0.0 M5 after March 21, 2007, you should ignore this patch.

If you download or install Java2Script 1.0.0 M5 before March 21, 2007, you may need to make a patch following the instructions:

Because of a not tested bug that the packed Common.z.js in plugins/net.sf.j2s.lib_1.0.0(.v510/.v520)/j2slib/org/eclipse/swt/widgets/ does not contain TabItem.js, which will result in errors of “$wt.widgets.TabItem is not a constructor” when loading Java2Script SWT application that uses TabFolder widget.

To fix up the problem, please download the patch, and unzip it, replace the old Common.z.js with the new Common.z.js.

If you also download the sources, please replace net.sf.j2s.lib/build/build.xml with the new build.xml.

If you have already installed Java2Script Firefox Add-on, please replace **Path to your Firefox profiles**/extensions/{d60b46a9-bfe3-4b22-8844-07089202e0e6}/chrome/content/
java2script/1.0.0-m5/org/eclipse/swt/widgets/Common.z.js with the new one. In Windows, Common.z.js may be in **System Drive**:\Documents and Settings\**Your Login Name**\Application Data\Mozilla\Firefox\Profiles\**Unique String**\extensions\{d60b46a9-bfe3-4b22-8844-07089202e0e6}\chrome\content\

I feel very sorry about the inconveniences.

March 21, 2007

Posted in Java2Script News | Leave a comment

Java2Script’s GTalk

I spent about three days writng an SWT based Google Talk client. And the client used Smack Jabber library, which has simple APIs. As writing the client, I kept the code compatible with Java2Script, which means that I can use the latest Java2Script daily release to pack it as a web servlet application and deploy it as rich internet application (RIA). Here is snapshot of Java2Script version of Google Talk:

Java2Script's GTalk

And here is the online Java2Script’s GTalk.

And because Java2Script’s SimpleRPC supports Cross Site Script, the above application can be loaded from any pages by adding the following HTML

Launch GoogleTalk

to your page.

Or you can just copy the above “javascript:…” part (without quotes) and paste it to address bar and go. You will get a Google Talk client (pure JavaScript) in your page (this page or other pages). This “javascript:…” part is considered as A Link An Application (ALAA).

By digging about Google Talk on, I found that Google Talk Gadget on Google’s personalized homepage was really hitting the latest news.

Enjoy it.


The Java2Script’s Google Talk sources are available at SVN repository now:

And you can also download, unzip it and deploy gtalk.war to your Java servlet container.

Posted in A Link An Application, AJAX, ALAA, Java2Script News, RPC, Screenshot, Simple RPC, SWT | 2 Comments

Compressed JavaScript on Apache HTTPD Server

As Java2Script’s library size is getting huger and huger, loading *.js is a critical job for Java2Script. And I decide to output compressed *.js to save loading bandwidth.

In httpd.conf or .htaccess file, add the following:

<IfModule mod_deflate.c>
# Netscape 4.x or IE 5.5/6.0
BrowserMatch ^Mozilla/4 no-gzip
# IE 5.5 and IE 6.0 have bugs! Ignore them until IE 7.0+
BrowserMatch \bMSIE\s7 !no-gzip
# Sometimes Opera pretends to be IE with "Mozila/4.0"
BrowserMatch \bOpera !no-gzip
AddOutputFilterByType DEFLATE text/css text/javascript application/x-javascript
Header append Vary User-Agent

You can read more about mod_deflate document.

In my experiments, I found that IE 6.0 had a strange bug in loading compressed *.js, so IE 6.0 was fed with huge raw *.js.

In normal bandwidth connection with Firefox 2.0, it takes about 16 seconds for the first time loading and running Java2Script application, and it takes about 6 seconds for later running (Cached *.js are applied). From the log file, there are about 20~30 *.js/*.css/*.png/*.gif hits, which counts up to about 150k. Thanks for the mod_deflate of Apache HTTPD Server. It saves a lot of bandwidth on those maybe 600k+ *.js files. And I considered such Java2Script application loading or running acceptable.

By the way, long waited Java2Script Milestone 5 release is coming. Lots of new features are added.

Update: For more details, please also read article “Compressing and Deploying JavaScript“.

Posted in Apache, JavaScript | Leave a comment

Reload:A Link An Application

Copy following as a link and paste in your browser address bar (A new tab or a new window, or other existed tab page[Maybe a Google search result page, not this blog page]):

javascript:if(a="$wt.examples.controlexample.ControlExample@",window["ClazzLoader"]!=null)$w$(a);else{var d=document,t="onreadystatechange",x=d.createElement("SCRIPT"),f=function(){var s=this.readyState;if(s==null||s=="loaded"||s=="complete"){$w$(a);}};x.src="";(typeof x[t]=="undefined")?x.onload=f:x[t]=f;d.getElementsByTagName("HEAD")[0].appendChild(x);void(0);}

According to your connection speed, it may take a few seconds before some Java2Script things come up. Enjoy it.

Replace the link’s “$wt.examples.controlexample.ControlExample @” with your Java2Script application URL. It’s class’s full name + @ + the class’s *.js bin root folder. If the URL is not very long (total javascript url string length < 500), it will be OK for modern browsers to load your application.

Posted in A Link An Application, AJAX, ALAA, JavaScript, Sharing, SWT | Leave a comment

Screenshot of Java2Script Web Notepad

I spent some time to enhance a web notepad with auto-save feature. Here is screenshot:

Java2Script Web Notepad

As a matter of security fact, it is not ready for public tests, so now I am not publishing the . Maybe later I will add more strict rules to the notepad so that no malicious modifications harm the system. Or maybe I will not take such a risk.

Actually, more desktop applications can be converted into rich internet applications. I even consider converting a terminal console into Java2Script web application is possible. But maybe I won’t do so.

Posted in AJAX, Java, RPC, Screenshot, Sharing, Simple RPC, SWT | Leave a comment