Monthly Archives: May 2006

Ajax web pages

Another demo about Java2Script SWT. It also show the coming features of exporting static HTML codes from the J2S SWT window besides showing abilities of reading web pages in AJAX way.
http://c.ognize.com/j2s-ajax-pages/

or ajax-web-pages at j2s.sourceforge.net

For a much faster view (HTML + CSS + a few lines of JS), please visit the exported static demo page

J2S with static HTML export support

Posted in Sharing, User Experience | 26 Comments

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

GWT v.s. Java2Script SWT

Google has released Google Web Toolkit (GWT), ….

Aha, google is doing the same thing as me: Java2Script Pacemaker.

The same pattern: Java-to-JavaScript compiler, provide general java.lang.* and java.util.*, and an extra UI widget library.
In Google Web Toolkit, the UI widgets is GWT, while in Java2Script Pacemaker, it is Eclipse’s Standard Widget Toolkit (SWT).It seems GWT is a much lighter library than SWT. Currently Java2Script’s SWT is growing to about 400k of *.js files for about 80%+ API support. After compression the file size is about 250k. 250k v.s. 100k. Hoho it seems J2S’ SWT need more works.

Some more comparisions of GWT and Java2Script:

  • Now GWT has no IDEs support but can be developed within Eclipse, while Java2Script Pacemaker is a plugin extending Eclipse JDT plugin, so its UI is Eclipse SDK. Java2Script is not a standalone application.
  • GWT’s UI may not be reused on desktop, while J2S’ SWT is another implementation of SWT’s API. That is to say, it’s SWT on Browser besides SWT on Win32, SWT on GTK, SWT on PPC, … So SWT applications developing for desktop can be reused or directly exported to web browser.
  • GWT’s UI is for web, and SWT is for both deskop and web. And J2S’ SWT looks more similar to desktop application.
  • GWT has been integrated with Java EE, while Java2Script is still not (Planned but not yet implemented).
  • For license, GWT is on its own license, J2S is licensed under the much well-known Eclipse Public License 1.0.
  • About releases, GWT is now 1.0.20, while Java2Script is before 1.0.0 M2 besides its ealier 0.1.0 to 0.5.0 and 1.0.0 M1.

Aha, Java2Script Pacemaker welcomes you.

/js (*_*)

Posted in Java, Java2Script News, JavaScript, Uncategorized | 11 Comments

J2S tutorial: Advanced Programming on J2S

Tutorial of J2S in Eclipse (7): Advanced Programming on J2S — @j2s* and others

josson smith
May 17, 2006
This article will describe more details on using Java2Script Pacemaker, including writing and debuging native JavaScript. Developer will learn how to debug and optimize their web applications beside the level of Java but also in level of JavaScript. This article aims those advanced Java2Script users.

Posted in How To, Java2Script News | 2 Comments

Will JavaScript 2 be the Future of the Web?

In “Brendan Eich: JavaScript 2 and the Future of the Web”, it says:

We were lucky enough to have Brendan Eich, creator of JavaScript, give a keynote at The Ajax Experience.

We have placed the presentation online so everyone can read up on some of the thoughts and discussion on JavaScript 2 and more.

Here we got to hear from the mouth of someone deep into the ECMA process about what we are going to see in JavaScript 2 and importantly why:

So I begin to think that: will the time interval 2006-2010 (4 years) be somewhat too long?

Are there useful tools to speed migration?
* A JS2 to JS offline translator, for example
* Write your web app using JS2 exclusively
* Run the translator over all of your JS2 code
* Serve the translated files to old browsers

The project Java2Script, which I am working on, is providing a Java to JavaScript convertor. To develop web applications, it recommends the way of writing JavaScript in Java Syntax (Actually writing Java totally by IDE and then converting Java to JavaScript).
But some comments sound

“Don’t turn it into Java!�?

These comments do bewilder me and make me think further.
From the above Brendan’s presentation, we can see a lot of syntax improvements, which are popular in Java, C++, Python or Ruby. Maybe we could call them syntax sugars. Sugars won’t be enough. Robust IDEs are needed to help writing or managing those scripts.
So I am thinking: Will JavaScript 2 be on a way of being another language if it is not adopted widely and quickly by Browsers and IDEs while JavaScript 1 keeps being popular? If such things happen, a maybe JS2 to JS converter will always be used. Then JavaScript 2 will be similar to other languages like Java, Python, as those languages also can be converted into JavaScript by convertors. Then a question: why wait 2~4 years or longer for JavaScript 2 syntax sugars? Why not having the syntax sugars of Python, Ruby, Java or C++ right now by convertors?

PS: It seems that I am being affected by Java2Script too deep to make such comments on JavaScript 2.

Posted in Java, JavaScript | Comments Off on Will JavaScript 2 be the Future of the Web?

Setup Java2Script Environment from Subversion Repository

Setup Java2Script Environment from Subversion Repository

Brief steps:

  1. Install Eclipse and Subclipse
  2. Checkout sources from SVN https://svn.sourceforge.net/svnroot/j2s/sources.
  3. Export projects as “Deployable plug-ins and fragments”
  4. Exit Eclipse and enhance JDT Core Jar
  5. Restart Eclipse and rebuild “net.sf.j2s.java.core” and “net.sf.j2s.java.org.eclipse.swt”
  6. Checkout tests from SVN https://svn.sourceforge.net/svnroot/j2s/tests and make tests

Details steps

Posted in How To, Java2Script News | 2 Comments

WebCream – Java(Swing and AWT) to HTML converter

I came up with this interesting website today:

WebCream – Java to HTML converter providing automatic conversion of Swing and AWT to HTML

If you are interested about this, here is its demo page.

Its technology is dynamically conversion of SWING/AWT to HTML, and the GUI events will  be sent back the server to update the page (Something like ZK?). But Java2Script is pre-compiling all the GUI codes into JavaScript, and then all events are dealt in the Browser sides except those remote calls to server.

Posted in Sharing | 409 Comments

Early J2S’ Eclipse JFace Dialog

I spent sometimes on converting Eclipse’ JFace codes, and got something like TitleAreaDialog:

Early J2S JFace

But it took about 2+s(4s for IE6 on my machine) to do such layout (this time does not include the 1+s loading the *.js). It was just an experiment for things. And J2S JFace won’t be released in J2S 1.0.0.

Posted in Java2Script News, JavaScript, Sharing, User Experience | Comments Off on Early J2S’ Eclipse JFace Dialog

Bugs about “Failed to load Main-Class …” in 1.0.0 m1

Bugs and Fixes

When running j2sui.jar an error message box about “Failed to load Main-Class manifest attribute from …” popups. And this is a bug when packing j2sui.jar. I realized this bug until these days. And another fixed packed are here:

http://prdownloads.sourceforge.net/j2s/j2s-1.0.0-m1-eclipse-3.1-fixed.zip?download

or make downloads from the updated download page .

And please stay tuned for the coming Java2Script 1.0.0 m2

Posted in Uncategorized | 6 Comments