Start Learning


Step 1: System Setup

Java Logo


Red Triangle  OVERVIEW

This article is a speedy introduction to creating Java ME applications for mobile phones and other small devices.

With all the recent interest in smart phones, it's easy to forget about feature phones, the ones that most of the world uses every day. Everything about feature phones is smaller than smart phones: they have smaller screens, less memory, slower processors, and a smaller price tag.

In the world of Java ME, the Java platform is based on two technologies, the Connected, Limited Device Configuration (CLDC) and the Mobile Information Device Profile (MIDP). MIDP builds on CLDC to define a Java platform with a small footprint, perfect for small devices like feature phones.

Billions of feature phones are deployed in the world today, and most of them already run the Java ME MIDP platform.

The Java ME SDK is a free desktop tool that makes it easy to create applications for MIDP devices. It includes sophisticated development tools as well as a desktop device emulator. This article describes how to create an application with the Java ME SDK, run it on the emulator, and run it on a real device.


The Java ME SDK is available for OS X and for Windows. Each download page contains detailed installation instructions. Before installing the Java ME SDK, you must already have a Java SE Development Kit (JDK) installed, version 1.6 or higher. On up-to-date versions of OS X, you already have JDK 1.6. On Windows, you must download and install the JDK first.

Run the Java ME SDK. On OS X, it looks like this:

Java ME SDK main window

You can click on any of the Sample Projects to load and run a project in the emulator. Click on LWUITDemo, for example. The application runs in the default emulator:


LWUITDemo on the emulator


The emulator simulates a touch screen phone. You can use your mouse to "touch" the screen. You can also use your keyboard to simulate pressing buttons on the phone. Here are some shortcuts:

Key Meaning
F1 Left soft button
F2 Right soft button
Enter Fire button
F4 Launch Application Manager
F5 Suspend application
F6 Resume application
F8 Rotate clockwise
F9 Rotate counterclockwise

Note that your operating system might use some function keys for other purposes. On OS X, for example, F8 and F9 are mapped to Exposé and Spaces, respectively; if you disable these shortcuts in System Preferences, you will be able to use the function keys for the emulator.

When you are finished, click the power button on the emulator to exit. The power button is shown here, circled in red:


Emulator power button


To run a project again, click on the run button Run icon.

You might enjoy checking out some of the other sample projects.

When you click on a sample project, it is loaded into the Java ME SDK. You can browse through the source code of the project in the upper left corner of the window. This screen shot shows the LWUITDemo project and some of its source code files:


LWUITDemo project expanded


Double-click on a source file to open it in the editor in the right side of the window.

When you are finished exploring the sample projects, you are ready to start your own application.

In this section, you will create a new project in the Java ME SDK, then define a simple application in it.

Choose File > New Project... from the menu, or click on the New project icon icon. In the window that pops up, choose Java ME SDK and MIDP Application, as shown:
New project window part 1

Click Next >. Choose a name for your new application, uncheck Create Hello MIDlet, and click Finish.
New project window part 2

Your new application appears in the Projects pane of the main window of the Java ME SDK.

The new application is going to use Lightweight User Interface Toolkit(LWUIT), which is an advanced user interface toolkit for CLDC/MIDP applications. You won't do much with it in this article, but if you're serious about creating compelling user interfaces, you will want to learn how to use LWUIT.

To add LWUIT to the new project, make sure the project is expanded to show Source Packages and Resources. Control-click on Resources and choose Add Library... from the popup menu.

Add a library to the project

Choose LWUIT and click Add Library.
Choose LWUIT and click Add Library

You can now use LWUIT in your project.

Cindy Church, Senior Curriculum Developer at Oracle, shows how to download and install the latest version of Java ME SDK.

Cindy also shows how to use the Java ME SDK to run sample applications in the mobile phone emulators provided with the SDK.

Next Tutorial: Create an Application