Java ME (Java Platform, Micro Edition) Programming

Java ME (Java Platform, Micro Edition) Programming

Wen-Chen Hu (University of North Dakota, USA)
DOI: 10.4018/978-1-59140-769-0.ch011


Most client-side handheld programming uses either Java or C/C++. This chapter introduces Java ME (previously known as J2ME), which is a version of Java (Sun Microsystem Inc., 2004). Java ME is a collection of technologies and specifications used to develop a platform that fits the requirements of mobile devices such as consumer products, embedded devices, and advanced mobile devices. It creates a complete Java runtime environment tailored to fit the specific requirements of a particular device or market. Java ME includes user interfaces, security, built-in network protocols, and support for networked and offline applications that can be downloaded dynamically. Compared to other client-side handheld programming languages, Java ME is light-weight and easy to learn, although this also means that Java ME may not contain as many features as other languages. Advanced Java ME programming will be discussed in the next chapter. Chapters 13 and 14 will discuss Palm OS programming, which uses C/C++.
Chapter Preview

Java Me Programming Steps

Figure 1 shows the Sun Java Wireless Toolkit© used to develop wireless applications that are based on Java ME’s CLDC and MIDP. The toolkit includes the emulation environments, performance optimization and tuning features, documentation, and examples that developers need to bring efficient and successful wireless applications to market quickly. The following steps show how to develop an MIDP application, in this case a simple “Hello, World!” program, under Microsoft Windows XP:

Figure 1.

A screenshot of KToolbar after launching © 2008 Sun Microsystems, Inc.

  • 1.

    Download and install Sun Java Wireless Toolkit 2.3 Beta, which includes a set of tools and utilities and an emulator for creating Java applications that run on handheld devices, at the URL (

  • 2.

    Run the development environment KToolbar of an MIDlet, an MIDP application, as shown in Figure 1 by selecting the following Windows options:

Start ⇒ All Programs ⇒ Sun Java Wireless Toolkit 2.3 Beta

⇒ KToolbar

  • 3.

    Create a new project by giving a project name such as HelloSuite and a class name such as HelloMIDlet as shown in Figure 2. After the project HelloSuite is created, the KToolbar will display the message shown in Figure 3, which specifies where the Java source files, application resource files, and application library files are to be put.

    Figure 2.

    A screenshot of the pop-up window obtained after clicking on the button “New Project” of KToolbar © 2008 Sun Microsystems, Inc.

    Figure 3.

    A screenshot of KToolbar after the project HelloSuite is created © 2008 Sun Microsystems, Inc.

  • 4.

    Create a J2ME source program and place it in the directory of the local disk (C:\WTK23\apps\HelloSuite\src\). Figure 4 gives a J2ME example, which displays the text “Hello, World!” and a ticker with the message “Greeting, world.”

    Figure 4.

    An example of a MIDlet program

  • 5.

    Build the project by clicking on the “Build” button. The “Build” includes compilation and pre-verifying.

  • 6.

    Run the project by clicking on the “Run” button. An emulator will be popped up that displays the execution results of the built project. For example, Figure 5 shows an emulator displays the execution results of HelloSuite.

    Figure 5.

    The screenshot of an emulator displaying the execution results of HelloSuite © 2008 Sun Microsystems, Inc.

  • 7.

    Upload the application to the handheld device using USB cables, infrared ports, or Bluetooth wireless technology.

Complete Chapter List

Search this Book: