Codename One, Cross Platform “Native” Development

Aldo Ziflaj

“Java is dead”

“dotNET killed Java”

are phrases I hear a lot these days. But is it true? Is Java really dead?

When compared to other languages like JavaScript, Python or Ruby, Java has a much steeper learning curve.

One does not simply kill the language of choice of 9 million devs. One does not simply kill the base language of Android. And finally, one does not simply kill The cross-mobile platform language.

Java on every mobile… wait, what?

Codename One is a way of creating native mobile applications for Android, iOS, BlackBerry and Windows Phone, using the same Java source code. Android native apps use Java, but iOS, BlackBerry and Windows Phone do not. Codename One makes translations of your Java code into the native code for each of these platforms, sometimes resulting in faster apps than the native versions.

Codename One is open source for both commercial and non-commercial usage.

Codename One vs the world

There are other platforms that do things similar to Codename One. Using Cordova/Phonegap you can develop hybrid cross-platform apps for every device. Appcelerator’s Titanium gives you the possibility of creating almost-cross-platform apps, using Javascript that is executed in a Javascript engine (Android and iOS only). There is Xamarin that uses C# for cross-platform development, but you still have to write some native code.

Codename One differs from all the above.

Codename One has the performance that a hybrid app cannot have. There is no 300ms delay with native apps. Creating apps with CSS and JavaScript can be difficult to debug, many of these issues wouldn’t happen developing with Codename One.

You don’t need to have a Mac for developing iOS apps, it doesn’t require any native SDKs. The app is built in the cloud, using a build server. After being built, the application can be downloaded to your desktop, or directly to a mobile phone.

Codename One’s build servers handle the work of changing Java code into native code and it produces surprisingly optimised code. With iOS, the translated Java code can perform up to 3x faster than native Objective-C code. The only thing faster than that is hand-coded C, not an easy task.

Obj-C vs CodenameOne


You can install Codename One in any Java IDE you want, such as Eclipse, NetBeans, and IntelliJ IDEA. Not Android Studio though as it uses a different build engine.

You can follow these tutorials for IntelliJ IDEA and NetBeans. I will show how to install with Eclipse.

In Eclipse, open Help -> Install New Software…, then Add… to add a repository with the name Codename One and with this location:

Adding Codename one repo

After that, select all items and accept the terms of agreement to install the Codename One plugin.

Accepting terms of agreement

After restarting the IDE you can create a new Codename One Project by pressing CTRL/Cmd+N and choosing CodenameOne Project from the wizard.

Creating a new project

Set your project name (I’m setting it to HelloCodenameOne). Next, you can set the main class name, the package, and chose a theme and template.

Choosing Theme

After clicking Finish, you will have a basic Codename One application, which you can run by clicking the Run button in the IDE. This starts the simulator, and Codename One comes with plenty of them.

Codename one emulators

How to GUI?

What every developer needs is a GUI Builder and Designer. Codename One comes with a Designer.

Codename One saves the UI in a resource file and can be designed without the source files available. Java is not required to make the GUI, you just drag and drop elements on the screen. The Codename One LIVE! application can show a live preview of your design as you make it.
You don’t have to worry about multiple dpi, because the Designer handles it for you by using an algorithm to scale the images for different screens.

To open the Designer tool, search for theme.res in your project and double-click it.

Code Structure

This will start the Designer tool where you can customize your theme, use the GUI Builder, fonts, images, and so on.

Codename one GUI builder

In the GUI Builder tab, click the Main button. On the right hand side of the screen you will see the basic design for the application. You can double-click on the labels that contain “Hi World” to change them. I’m setting one to “Hello CodenameOne” and the other to “First CodenameOne App”.

Save this and restart your application. Your new application should look like this:

Application running in emulator

The Build Server

To send your new application to the build server, right-click on the project and select to CodenameOne -> Send {{platform-name}} build. Then login to your CodenameOne account, and the application is sent to the build server for adding the finishing touches, and can be downloaded.


It uses the most used programming language in the world, the best and most popular IDEs, it is fast, and it helps you deploy everywhere native. It is the best Java iOS tool that conserves the “Write Once, Run Anywhere” (WORA) principle.


Of course after so many positive points there have to be some negatives. With Codename One it’s mainly cost. Whilst a lot of the features discussed above are available to experiment with for free, to move your apps into production you’re likely to need one of their commercial offerings. Weighing up the cost benefits of WORA vs the Codename One costs is a decision you will need to make.