Java for mobile applications

Although Java originally had been designed as a language for simple electronic applications, it nowadays is primarily used in heavy (often clustered) server environments. In cases where enough memory and considerable processor power is available, this uncomplicated language delivers practical results in a flexible way. Something which does not seem to agree with the limitations of most mobile devices. But more and more PDA’s and mobile phones offer a Java runtime environment, and indeed running usable software. How does Java function for mobile applications, and when do you choose Java over alternatives like xHTML?

In harmony with Java

There are two reasons why mobile devices get along well with Java. Firstly, the language architecture can easily be adapted. You do not have to use the many layers, design patterns and EJB’s which are typical of a heavy Java architecture. Instead of an excess of layers and accompanying interfaces the programmer simply uses POJO’s (Plain Old Java Objects) to write a ‘lean and mean’ program that works well with memory restrictions. With POJO’s the applications regain their nice small size, and are much faster as well. The second aspect enabling mobile Java is the existence of a specific runtime environment. A dedicated Java ME environment is available to develop mobile applications, alongside the standard SE development environment (for desktop support) and Java EE for server applications. Although Java SE is always used in the development environment, even if you program exclusively for server or mobile use, the runtime environment of ME is complementary and makes it possible to run the developed applications on modest systems.

Java ME

Most Java development environments currently support Java ME and offer an emulator to test the results. Java ME can be downloaded for free from Sun, providing API’s, documentation and a simple toolkit to set up projects. The most important library, javax.microedition, enables control of the user interface on various small devices (see also image). Working with Java ME is relatively simple, and it can be used to develop excellent applications. The supplied emulator tests the designs easily. On top of that, Sun offers several sample applications including the source code.

Java of xHTML

Anyone with some understanding of Java will agree: there are plenty of possibilities for mobile Java applications. The question remains when to choose Java, en when to choose a different approach. That is an easy one, I think. If the existing applications are structured according to a classic three-layer model (database, server, client), and the mobile phone can function as a client, then xHTML will often be the preferred choice, mainly because of the speed of development and use. If GPRS, UMTS or other connectivity options are limited, and if it is desirable that the device performs optimally, also regarding graphics, then I would certainly choose Java.

Sun.com

For more information on Java and to download Java ME immediately, see http://java.sun.com/javame/.