Category Archives: Java

Gmail-alike Web Mail Client “WeMail”

Long time no post.

This time, I would like to introduce you Java2Script powered WeMail ( http://webuzz.im/mail/ ), a Gmail-alike web mail client. WeMail is a general web mail client for all POP/IMAP & SMTP mail providers. So it supports Gmail, Hotmail/Live Mail, Yahoo! Mail, AOL/AIM Mail and others.

WeMail currently provides Gmail demo accounts for demo: after the page is loaded, select “java2script.demo” or “java2script.talk” from email drop-down list and then login. You can compose and send new emails (Drafts are auto-saved). You can read and reply emails. Folder Drafts, Sent Mails, All Mails, Spam and Trash are supported. Setting, Search and Contact is not supported yet.

Screenshot of WeMail Web:
wemail-list

Screenshot of WeMail Desktop:
wemail-desktop

You can also visit WeMail development blog for more screenshots

WeMail is based on Java, JavaMail, SWT and Java2Script technologies, designed by Eclipse & WindowBuilder Pro. Here is WeMail development summary:

  • First, design WeMail using WindowsBuilder Pro designer. Designing UI takes a lot of the time.
  • Second, import JavaMail, separate email jobs into several Simple RPC classes and implement them using JavaMail API.
  • Third, run and debug WeMail as a normal desktop Java application. Everything is about native Java development.
  • Then, use Java2Script plugin to compile WeMail Java sources into JavaScript.
  • At last, “Running as Java2Script Application”, customize a few lines of the generated JavaScript.

Why implementing another Gmail-alike web mail client?

  1. People likes to see Google products powered by GWT’s Java to JavaScript technology. But there is no such GWT-powered Gmail by now. Java2Script powered Gmail-alike web mail client proves this concept. And it only takes less than 2 weeks.
  2. WeMail provides the abilities to use Gmail UI for other mail providers besides Gmail, like Hotmail or Yahoo! Mail. Gmail UI may increase people’s daily email processing efficiency.
  3. WeMail provides people another way for accessing to Gmail, Yahoo! Mail or other mail providers, in cases accessing to certain websites is blocked.

BTW: Along with development of WeMail, there are a few Java2Script updates (compiler bug-fixing and SWT library improvements). Please check it out.

Posted in Java, Java2Script News, Simple RPC, SWT, WindowBuilder Pro | Tagged , | 140 Comments

Java and JavaScript

Today, I came up with the idea of “Orto: Java in JavaScript“. Well, it is not “Java to JavaScript”, it is “Java in JavaScript”. It is said that java.lang.Thread is supported. But as there is no downloads available, and it is not open source, so I could not test it.

Supporting Thread programming in JavaScript would be cool. Once I spent some time trying to figure out how to support Thread in Java2Script project, but I failed. But I managed to program execute codes asynchronously by using SWT’s Display#timerExec(int, Runnable) or Display#asyncExec(Runnable) instead. So even though I can not use Thread#sleep, I still can do lots of thread things.

And Orto seems to be in a different way to support Thread, the codes it generated look like these:

case 117:orto246[orto247-2]={high:(~orto246[orto247-2].high)
&0xffffffff,low:(~orto246[orto247-2].low+1)&0xffffffff};
if(orto246[orto247-2].low==0){orto246[orto247-2].high++;
orto246[orto247-2].high&=0xffffffff;
orto246[orto247-2].low=0;
}break;

Compiling to Java code into byte-code like script, and loading and running these scripts in “JVM” should be a way to support all Java things. In my opinions, all locks and threads are re-implemented. Performance should be a problem. I know that there is another project called XML11, which is also trying to compile Java codes into JavaScript byte-code.

And recently, I also noticed that there was a debate about GWT Ext or Ext GWT. You may already know that GWT is about compiling Java to JavaScript and Ext JS is a HTML/CSS+JavaScript based UI library. It is interesting to see people combine these two technologies together. And it is more interesting that putting GWT before Ext JS and putting Ext JS before GWT is two different things. You may want ot read Didier Girard’s discussion for a clear idea.

About 2 years ago, when I started Java2Script project, I had to think about its programming model. At that time, people began to wrap existed JavaScript library in Java way. I called it “JavaScript for Java (JavaScript4Java)”, which is quite different from my “Java to JavaScript (Java2Script)”. So “2” and “4” is totally different, right?

In fact, I do know that Java and JavaScript are two different language. The reason that I chose Java as the source and JavaScript as the target is that Java is most beautiful and most used language while JavaScript is a world wide supported language. And I am familiar and love Java language. So I created Java2Script. I do believe that C#-to-JavaScript, Ruby-to-JavaScript or Other-to-JavaScript is not a big deal for me. But I may not have energy to make a similar compiler.

Java and JavaScript may be hotter and hotter. Good to see that more and more people is linking Java and JavaScript together.

Posted in Java, JavaScript | Tagged , , , | 35 Comments

Eclipse RAP 1.0 Comes

Eclipse RAP team has just released its 1.0.

The RAP project enables developers to build rich, Ajax-enabled Web applications by using the Eclipse development model, plug-ins with the well known Eclipse workbench extenstion points, JFace, and a widget toolkit with SWT API (using qooxdoo for the client-side presentation). The project has graduated from incubation and released its 1.0 release.

In fact, Eclipse RAP and Java2Script have a lot in common. Both are based on SWT API and have goals to provide ways for developers to share the same base of code for products that deploy to the web and the desktop. Here is overview of Eclipse RAP. And you can also read Java2Script’s overview for comparisons.

And you can also check out Eclipse RAP demo to get more details. It’s interesting to see that RAP and Java2Script have 2 very similar demos: RAP’s RWT Control Demo and Java2Script’s SWT Control Examples.

More discussion may be found at ajaxian.com.

Related link: InfoWorld Eclipse offers AJAX server

Posted in AJAX, Java, Sharing, SWT | 2 Comments

Java2Script 1.0.0 Final Release

Here comes Java2Script 1.0.0 final release!

Please visit http://j2s.sourceforge.net/ for more information.

Feature List
==========

Java2Script Core
—————-
1. Object oriented JavaScript simulator is introduced
2. JavaScript ClassLoader is built inside
3. Eclipse JDT based Java to JavaScript compiler, support Java 1.4 and Java 5 features, including generic, enums, static imports, enhanced loops
4. Support incremental building for Java projects
5. Support Hotspot JavaScript swapping for debugging
6. Support most classes in java.lang.*, java.utils.* and others packages
7. Support native JavaScript through @j2s* Javadoc in Java sources
8. Support creating Java2Script projects by wizard, including Servlet project
9. Support loading *.js from Firefox Add-on.
10. Support Eclipse 3.1.*, 3.2.* and 3.3.*

Java2Script SWT
—————
1. Eclipse SWT 3.1 API is ported for JavaScript in modern browsers, Firefox, Internet Explorer, Opera, Safari
2. Window manager is built inside
3. Support UI blocking fow SWT’s Shell and Dialog
4. Support SWT deffered layout
5. Support detecting font size change in Firefox

Java2Script AJAX
—————-
1. HttpRequest/AJAX is introduced for both Java and JavaScript
2. Simple RPC API is introduced to call back Java server, which supports Cross Site Scripting
3. Support dynamic class loading for both Java and JavaScript
4. Support Java reflection (early implementation)

Java2Script JUnit
—————–
1. Support JUnit tests both Test Case and Test Suite in text mode.

Java2Script Example
——————-
1. Google Talk in JavaScript ( http://demo.java2script.org/gtalk/ )
2. SWT Control Examples ( http://demo.java2script.org/controls/ )

For more feature detailed description, please visit:
http://j2s.sourceforge.net/features.html

Posted in AJAX, Java, Java2Script News, JavaScript, RPC, Simple RPC, SWT | 343 Comments

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 | 6 Comments

Java2Script Introduces Simple RPC

Java2Script now introduces Simple RPC, which is aiming to help Java
developers balancing and debugging *local* and *remote* procedure calls for AJAX RIAs without knowledge of serialization and deserialization.

In Simple RPC, Java client have two modes: AJAX mode and local Java Thread mode (Default mode).
Here are some simple words describing the procedure of developing AJAX RIAs with Simple RPC.

1. Java developer can debug those procedure calls in local Java Thread mode with local Java SWT client.

2. After functions implemented, they can add a Java servlet wrapper (Java2Script provided), export all things as a JAR file and deploy it to Java EE container.

3. And now switch Java client to AJAX mode (set some static variables) and test whether the deployed servlet is OK or not.

4. If not correctly deployed or bugs popup, developers can switch back to local Java
Thread mode and do their debugging again.

5. In the end, use Java2Script compiler to compiler the Java SWT client into JavaScript RIA client and test it in browser.

For more details, please check out latest codes from SVN.

Posted in AJAX, How To, Java, Java2Script News, RPC, Simple RPC | 2 Comments

Java-JavaScript Compiler Discussion

Ash mentioned Java2Script in the thread of “Java-JavaScript Compiler” in GWT’s group forum. And I joined in the discussion. I was not intended to post another GWT v.s. JavaScript post there (But it seems it was a v.s. thing actually). I just wanted to share things, correct my understanding and learn new things.

In those discussion, Bruce from Google told us that GWT’s motivation is “to be as small and as efficient as possible” and its two separate goals are:
(1) Create highly optimized JS output
(2) Optionally, publish selected parts of your code with a JS-compatible API
I thought that wais a very clever design. And I admired GWT team for its “excellent 100k ~ 200k final *.js files with very good performance”.
OK, if you are interested in Java to JavaScript technology, just go to GWT’s forum and ask GWT team for more details.

By the way, it seems that Java2Script website provides no detailed documents about Java to JavaScript compiler technology. I posted some details there in the discussion. Just check it out there. Or you can check sources from SVN for more details.

Posted in Java, JavaScript, Sharing | Leave a comment

Java2Script 1.0.0 Roadmap

Road to Java2Script 1.0.0 release:

  • 1.0.0 M3 will be released at Aug 20, 2006.
    In this release, main features include

    • Full support of Eclipse 3.2.0 beside Eclipse 3.1.*
    • No more need of extra JDT core jar enhancement
    • Dynamic JavaScript loading
    • Early Java reflection implementation
    • JUnit support
    • CTabFolder, Table, Combo, Spinner, ProgressBar, Scale improved
    • Early key navigation support
    • Lazy layout improved
    • Support more look and feels
  • 1.0.0 M4 will be released at about Oct 9, 2006. In this release, all features should be locked.
    Coming features include

    • CoolBar, ToolBar, Menu, ColorDialog, FontDialog, more custom widgets improvement
    • Look and feel manager
    • Key navigation system
    • DND system improvement
    • Windows manager
    • Extension points for RPC calls (only interfaces with a very simple reference implementation)
    • Bug-fix of M3
  • There is no 1.0.0 M5 but will be 1.0.0 RC release at Nov 11, 2006
    Works to be done include

    • Dynamic JavaScript loading performance tunning
    • Packing system tunning
    • J2SClazz core packing and zipping
    • J2S SWT performance tunning
    • J2S SWT packing tunning
    • Benchmark system for Java2Script
    • More integration tunning
  • The final release of 1.0.0 will be released in later December, 2006, about one year after Java2Script is open sourced. All thing may depend on feedback of 1.0.0 RC.
    Works to be done include

    • More tutorials
    • White paper
    • Demo projects using Java2Script
    • Documents
    • Lots of XXX v.s. J2S to tell developers about advantages and disadvantages of J2S.
Posted in Java, Java2Script News, JavaScript, Sharing | 51 Comments

A Link An Application

For example:

javascript:(function(){var d=document,b=%22http://java2script.ognize.com/1.0.0-m3/%22,t=%22onreadystatechange%22,x=d.createElement(%22SCRIPT%22),f=function(){var s=this.readyState;if(s==null||s==%22loaded%22||s==%22complete%22){var c=%22org.eclipse.swt.examples.controlexample.ControlExample%22;$CL1(b);$CL2(b+%22../control-examples/%22);$CL3(c,function(){eval(c+%22.main([]);%22);});}};x.src=b+%22j2slib.js%22;(typeof x[t]==%22undefined%22)?x.onload=f:x[t]=f;d.getElementsByTagName(%22HEAD%22)[0].appendChild(x);return;})();

will link to an SWT control examples. We can also call this as “A Link An Application”(ALAA).

OK, let’s see what is going on. Now load SWT control examples from java2script.ognize.com (test site only, may be slow and unstable, enjoy it) into this page.

Or, you can copy the link of SWT control examples, and then visit a new HTML page, for example, visit Google, and then paste the link to the location, and then go. You should find the SWT control examples will be loaded inside Google’s page. All you dealing with is just a link! But you alreay get an application everywhere inside your browser.
Users can also bookmark the “javascript:…” links. To bookmark a “javascript:…” link, you should first bookmark a normal HTML page, and then copy the “javascript:…” link location and paste as URL location in the bookmark’s properties dialog. Some browsers (e.g. Opera) will let you change URL when you’re bookmarking without a later modification of URL.
And whenever users want to load the application, users can click the bookmark, which will bring up the application in users’ currently visiting HTML page. For example, if you have already bookmarked the above SWT control examples application as “javascript:…” link. And if you are visiting visit W3C, and you can click the bookmark, and the application will be loaded without leaving the W3C pages.

That is the mean of “A link An Application”. A “javascript:…” link is an application, which may be hosted inside any given HTML pages. And the “javascript:…” link would be a very useful and complicated application besides those simple “javascript:history.go (-1);” or “javascript:alert(document.lastModified);”. So there are chances that you can deliver your useful and complicated web applications via generated “javascript:…” links into any other HTML paes or other web applications.

You can also considered the “javascript:…” link as plugin extensions to the browsers that needs no installations (Only bookmarking). There are plugins for Firefox or IE. Most of those plugins need installations and may also need manually updates or uninstallations. But the “javascript:…” links is free of those deployment instructions. All the application is just a “javascript:…” link. That is enough simple.

A link is an application. An application is a link.

Posted in A Link An Application, ALAA, Java, Java2Script News, JavaScript, Sharing, SWT | Comments Off on A Link An Application

Position is Everything

Currently, J2S’ SWT widgets are on the way of being pixel-precise. And some certain pain things come up:

1. Different browsers

IE (IE6/5.5/5.0 and IE7, too many, I mainly work on IE6), Firefox (Different versions will render position in some slight differences), and Opera (Just check out to see if there are ugly looks in Opera 8+, no pixel-precise supports)

2. Native SWT implementation v.s. browser implementation

I have to debug into the native SWT implementation, and look for the native positions of different widgets, and then debug into the JavaScript’s SWT implementation to see if the positions match. And thanks a little, the JavaScript is actually the Java codes, so I can do refactors or navigate between codes easily by Eclipse. And J2S’ inner console also helps a lot for printing out those necessary values. The procedures is something like developing C codes for Java to call through JNI.

3. CSS layout v.s. JavaScript layout

The SWT implementation requires both CSS layout and JavaScript layout. CSS is powerful, but it’s also too complicated and it has its pitfalls on dynamical layout and it can not tell complicate rules. JavaScript’s layout is free to anything but requires extra CPU times on calculating positions. And the position is mixed up with all kinds of CSS styles, for example, different “font-size”s, different “border”s, different “margin”s, …

4. What about supporting different CSS templates

…en, big thing, until almost 90%+ SWT APIs are implemented. …

Actually J2S’ SWT will hide the above pains from SWT developers.

SWT developers or web application developers only need to develop the native SWT applications and then enable Java2Script compiler for the Eclipse project. Then the compiler will convert Java things into JavaScript. After packing the generated resources (image and css and javascript) up with the J2S SWT libraries. You will get your web applications. You won’t have the above pains, as those pains belong to J2S SWT team.
Here following is a testcase snapshot.

Native Win32 SWT window:
Native SWT Group and TabFolder

Converted J2S SWT window in IE6:

J2S' SWT Group and TabFolder

Posted in Java, JavaScript, Sharing | 1 Comment