O'Reilly logo

Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition by Jim Holliday - Editor, Aleksi Uotila, Mark Patel, Jyri Huopaniemi, Jim Van Peursem, Antero Taivalsaari, Roger Riggs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

7.1. MIDlets

In MIDP, the basic unit of execution is a MIDlet. A MIDlet is a class that extends the class javax.microedition.midlet.MIDlet and implements a few methods—including startApp, pauseApp, and destroyApp—to define the key behavior of the application.

As an example of programming with the MIDP application model, consider the following program that implements one of the simplest MIDlets possible: the canonical “Hello World” application.

 package examples; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class HelloWorld extends MIDlet implements CommandListener { private Command exitCommand; private TextBox tb; // Constructor of the HelloWorld class public HelloWorld() { // Create "Exit" Command so the user ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required