Wednesday, May 28, 2008

Java Day and LWUIT

Earlier this week, on Monday, I've been to Sun's 2nd Annual Java Day here in Israel. It is a kind of a mini version of the famous JavaOne conference (which is held in San Francisco).

The conference started with keynotes from Boaz Yehuda, Sun Israel's CEO for quite a lot of years (I know him for almost 8 years now) and Vineet Gupta, Sun's Java CTO and then split to tracks including a mobile track which yours truly naturally went to (Surprise surprise)...

The highlight of the conference for me and for other technologists and developers I spoke with during the conference and afterwards was definitely LWUIT. LW what now you ask?.. Well LWUIT is Light Weight User Interface Toolkit. It is developed in Sun's development center in Israel and was announced recently at Sun's JavaOne conference about 2 weeks ago (And has been making a lot of buzz in the J2ME community since).

LWUIT solves one of the pains that J2ME developers handle with since... hmmm.. well, since J2ME existed... The thing is that the UI classes in J2ME are very basic, and moreover render differently in every device. Moreover, their implementation is bug infested, and it seems that every handset vendor has its own "interpretation" on the spec provided by Sun.

This led most if not all J2ME developers not to use J2ME's UI and instead develop their own UI over low-level classes that the platform supplies (Canvas). Now, obviously UI development is not at the business core of most companies (Aside from UI companies...), but many simply had to really dig deep and develop all sorts of proprietary UI, to supply some kind of a decent experience for their users.

According to the development team from Sun who developed it in their labs in the last couple of years, LWUIT comes to bridge between the current situation and what's to come at newer versions of MIDP (And mobile technologies in general).

The result is very impressive. I downloaded the demo app and played with it on a couple of devices and it works quite smoothly (Better on Sony Ericsson as usual...), and also took a look at the API (And part of the 115-pages developer guide...) - and it looks very comprehensive and well-thought through.

LWUIT supports a lot of cool stuff such as screen transitions (Fade, flip and even 3D cube), themes for dynamic look and feel of the UI and most importantly it features a real UI model that resembles Swing (Container-Component model) including a layout manager with several layouts, menus, tabs, animations, standard components that render nicely (buttons, checkboxes, dropdown lists etc.) and event handling. Simply put, forget everything you knew about GUI in J2ME - this is a different story...

The toolkit also includes a resource editor in which graphic designers can design the look and feel of the UI and the various themes - load backgrounds and animations, set colors and fonts to the various objects on screen and more. Now granted this is not as user friendly as Photoshop, but a tech savvy designer/HTML-ist can probably handle it.

In addition LWUIT is already integrated with NetBeans Matisse GUI builder, so you can basically build an application by dragging and dropping components (That is unless you are a real programmer of course ;)

What's the catch? Well, the footprint of LWUIT is not that small, but then again also not that big for today's devices. The PPT at the conference claimed that it can be as small as 50KB (Don't know if that includes everything). The demo app, which is basically LWUIT and classes that demo all its capabilities is 123KB (Without any resources).

It also supports MIDP 2.0 and up, so if you're planning to use MIDP 1.0 - forget it... (But you probably forgot MIDP 1.0 before LWUIT anyway...). On the porting issue, LWUIT promises to work on all MIDP-2.0 compliant devices with the same JAR, and indeed I've seen it running on a multitude of devices, but I'm sure there are weird JVMs out there just waiting to crash with it...

Anyway it looks like a good solution, and if you're not sure whether to use it in your project at least take a look at it, there's a lot to learn from the API. In terms of licensing you can integrate it even in commercial apps. However changes to LWUIT itself if you make them should be shared back to the community as it is open sourced under the GPL+CPE license (Anyway the source code is not available yet in the site - so we dodged that bullet...)

The toolkit can be downloaded from LWUIT site (There's also a video demo of the demo app). For more info you can check out Shai's Java & LWUIT Blog (Shai is on the LWUIT R&D team).

Thumbs up for Sun for making it up for us after all these years... Keep up the good work! I am looking forward to the next Java Day to see what will we see from Sun's Israeli labs this time...


P.S. - A year ago in Sun's 1st Annual Java Day in Israel, Sun's UI team guys saw our GamearraY application and were fascinated with the GUI capabilities that included animated menus and other shiny UI components, and said they haven't seen anything like it... Now I understand the full scope of this compliment.. obviously these guys saw and did things in this area...

2 comments:

Anonymous said...

This sounds similar to j2me polish. Any quick word on how these two compare, if you have any idea? btw, even polish has ~50k overhead.

Ofir Leitner said...

J2ME polish does not handle UI only, it is a library that helps with other aspects of J2ME programming such as Storage, Porting, networking etc.

Polish's UI module (called Lush) is much richer than LWUIT and offers more widgets etc. This is obciously since it's been around for a longer time. It should have a bigger footprint but they claim to have 40k footprint. Haven't tried it myself so can't say. Also, I am not sure how portable they really are (same for LWUIT by the way).

However, if you use polish's UI, you have to obtain a commercial license (or open-source your own application), while LWUIT license allows using it for commercial applications as well (As long as you don't modify LWUIT itself, you don't have to open source your app).

Another difference I see is that LWUIT is provided by Sun and not a third party. I believe this will help to gain the trust in the developers community (Although third party projects like polish and Apache were widely adopted too)