JAVA MOBILE - START LEARNING
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.
DOWNLOAD AND INSTALL JAVA ME SDK
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:
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:
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:
To run a project again, click on the run button .
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:
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.
CREATE A PROJECT
|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 icon. In the window that pops up, choose Java ME SDK and MIDP Application, as shown:
Click Next >. Choose a name for your new application, uncheck Create Hello MIDlet, and click Finish.
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.
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.