Shai has been developing software professionally since the 1990 and developing in Java since 1996. Shai formed a software consultancy in 1999 through which he consulted extensively to Sun Microsystems, IBM, Banks, cellular Operators, device manufacturers and startups. Shai has worked on countless projects in multiple fields within the industry. Shai is currently the co-founder and CEO of Codename One which is an open source initiative to reclaim Java's role as a client side development tool by bringing WORA to all mobile platforms. Shai has posted 3 posts at DZone. You can read more from them at their website. View Full User Profile

Codename One - Making WORA Real Again For Mobile Devices

  • submit to reddit
The iPhone was the first major phone to launch without Java, changing the landscape dominated by J2ME into a reality with a different kind of fragmentation. The open source Codename One project unifies the mobile platforms (iPhone, Android, Blackberry, Windows Phone 7 etc.) into a single API and tool stack based on Java. It allows developers to write code in Java and get native applications that can be installed on all mobile phones legally.

Codename One binds together years of work from multiple projects in the Java space to create a single coherent environment while allowing you to leverage the full power of Java tools directly from NetBeans/Eclipse. The API is Swing like with many improvements (proper styles/theming, painters, animations etc.) & yet allows full access to the underlying native device code. A standard GUI builder, simulator & IDE plugins are included and are all open source.
Seeing is believing so lets jump right to the code... After installing the Codename One Plugin (available for Eclipse/NetBeans) we now have a new Codename One project entry.   

 Codename One on the iPhone simulatorCodename One Android SimulatorCodename One Blackberry Torch Simulator

  We can create and run a new GUI builder hello world or non-GUI builder project in 30 seconds just by following the Wizard.
There is an active developer community forming around Codename One which can help you get started with the tool and answer the obvious questions.

Where's the catch?
There are several things you need to know:1. For maximum compatibility Codename One currently limits you to CLDC 1.1 syntax of Java. You can remove this limitation (by changing the build.xml file) but you will forfeit RIM/J2ME compatibility in the process.Even if these platforms aren't important to you we still wouldn't recommend doing this since you are more likely to stumble onto a Java SE feature that isn't supported by a target platform. In the future Codename One intends to slowly add additional API's and features from Java SE in a compatible and controlled manner.

2. Building for device requires sending the build to the server, this removes the need of owning a Mac for iOS builds or a Windows 7 machine for Windows Phone/Blackberry builds. Since Codename One is open source you can build locally from the source repository but its a very complicated process.  Using the build server is free for reasonable usage and we intend to keep it that way.

3. Currently you can't change the classpath. We intend to add a library mechanism which will allow 3rd parties to include "native" code in the library. You will need all your code in CLDC 1.1 source form, most of the API's you will need (XML/JSON parsers, UI etc.) are already included in Codename One.

 4. Codename One is new and its a work in progress, manage your expectations accordingly. However, we are very fast with the fixes and due to the years invested in the open source projects underlying Codename One the infrastructure is very solid. I will write more about what you can do with Codename One and how to accomplish it in a future post.
Published at DZone with permission of its author, Shai Almog.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Christian Schli... replied on Tue, 2012/04/10 - 2:59pm

Thank you very much for this post!

Jordi Böhme López replied on Fri, 2012/07/27 - 5:45am

Making WORA Real Again For Mobile Devices? Thats not quite right...

There is Tabris out there that makes Write Once Run Anywhere real, too - as well with Java - but uses native Widgets instead of a theme or static graphics - so it looks/feels better imho.

Shai Almog replied on Fri, 2012/07/27 - 7:05am in response to: Jordi Böhme López

If I understand correctly Tabris is a "runner" platform/server based container solution.

While it might be fine for some it is NOT like Codename One which is a true native mobile platform that generates a standalone native application that's unique, royalty free and allows invoking native device code (objective-c, dalvik etc.).

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.