Home > Store

Enterprise J2ME: Developing Mobile Java Applications

Register your product to gain access to bonus material or receive a coupon.

Enterprise J2ME: Developing Mobile Java Applications


  • Sorry, this book is no longer in print.
Not for Sale


  • Copyright 2004
  • Edition: 1st
  • Book
  • ISBN-10: 0-13-140530-6
  • ISBN-13: 978-0-13-140530-1

Industrial-strength J2ME™ for enterprise developers, architects, and decision-makers

J2ME offers an extraordinarily flexible and robust platform for developing mobile applications with enterprise-class performance, reliability, and value. Now, leading mobile developer Michael Yuan covers every aspect of building industrial-strength applications with J2ME: design, architecture, tools, processes, business issues, and more.

Yuan introduces innovations that make the platform even more powerful, ranging from new J2ME profiles and wireless messaging APIs to mobile databases and web services tools. These innovations allow existing Java™ developers (especially J2EE™ developers) to leverage their skills and add mobility to enterprise applications. Yuan also presents more than a dozen complete sample applications—including the application that earned him the grand prize in Nextel, Sun, and Motorola’s nationwide wireless developer contest. Coverage includes:

  • Patterns and best practices for building end-to-end mobile applications
  • Emerging mobile “killer applications”: driving productivity and cost reduction
  • “Smart client” applications: architecture and construction
  • Advanced HTTP techniques for authentication and session tracking
  • Overcoming hardware and network limitations
  • Leading-edge mobile enterprise messaging techniques
  • Mobile databases and synchronization engines
  • XML and mobile web services, including the J2ME Web Services Optional Package
  • New options for mobile security in the enterprise


Source Code

Untitled Document

Download the complete source code and build instructions for the example applications related to this title.



Related Articles

Programming for the Mobile World

Using the Java Wireless Toolkit


Untitled Document

To facilitate your work with the resources mentioned in the text, below please find links to Web-based references mentioned at the end of the chapters.

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Chapter 16

Chapter 17

Chapter 18

Chapter 19

Chapter 20

Sample Content

Online Sample Chapter

Overcoming Challenges in Mobile J2ME Development

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents


About the Book.



1. Mobile Commerce: Visions, Realities, and Opportunities.

Mobile Commerce Value Propositions. Mobile Technology Adoption. The Search for Killer Mobile Applications. Mobile Commerce Landscape. Summary. Resources.

2. J2M 2ME: Is Mobile Java Ready for Enterprise?

Why Java? The Java Community Process. Java Everywhere. Java 2 Micro Edition Explained. Competing Technologies. Summary. Resources.


3. The Smart Client Paradigm: iFeedBack.

Benefits of Smart Clients. Introducing iFeedBack. iFeedBack Usage Scenarios. Implementation Walk Through. Summary. Resources.

4. Managed Smart Clients.

Container-Managed Applications. OSGi Containers. A Simple Echo Service Example. Smart Client with HTTP Front End. Mobile Gateways. Summary. Resources.

5. Mobile Design Patterns: The Smart Ticket Blueprint.

Getting Started. Smart Ticket in Action. Important Architectural Patterns. Implementation Techniques. Summary. Resources.

6. Advanced HTTP Techniques.

The Decorator Approach. The Process-Chain Approach. Session Tracking via HTTP Cookies. HTTP Basic Authentication. HTTP Digest Authentication. Secure HTTP. Summary. Resources.

7. End-to-End Best Practices.

Limited Device Hardware. Slow, Unreliable Networks. Pervasive Devices. Ubiquitous Integration. The Impatient User. Summary. Resources.


8. Email and PIM.

Basics of Email. Introducing Mail4ME. The JavaPhone API. The PDA Optional Package. Commercial Email and PIM Suites. Corporate Portal Servers. Summary. Resources.

9. Converged Mobile P2P 2P Messaging.

Introducing the Wireless Messaging API. WMA in Action. WMA Reference Implementation. SMS from the Backend. Beyond SMS: The IM Convergence. SIP-Based IM Applications. Summary. Resources.

10. Enterprise Messaging.

Mobile Enterprise Messaging. Introducing the JMS. Mobile JMS from iBus//Mobile. The IBM WebSphere MQ Everyplace. Summary. Resources.


11. Mobile Database for CDC Devices.

Database on the Go. Introducing JDBC. Portable and Efficient Code Using PreparedStatement. Access Stored Procedures Using CallableStatement. The JDBC Optional Package for the CDC. HSQL Database Engine. iAnywhere Solutions SQL Anywhere Studio. IBM DB2 Everyplace. Oracle9i Lite. PointBase Micro Edition. Example Application: Contact Manager. Summary. Resources.

12. Mobile Databases for MIDP DP devices.

PointBase Micro Edition. The Oracle J2ME SODA SDK. The IBM DB2e FastRecordStore. Summary. Resources.

13. Database Synchronization.

Synchronization and Mobility. PointBase UniSync. IBM DB2 Everyplace. iAnywhere Solutions MobiLink. Oracle9i Mobile Server. The Synchronized Contact Manager. Summary. Resources.

14. Access Backend Databases.

Direct Access to Remote Databases. The Oracle J2ME SQL SDK. Legacy Applications. Using Simplicity for Legacy Databases. Summary. Resources.


15. XML for Small Devices.

What Is XML? Challenges for Small Devices. XML Parsing Models. Introducing Amazon XML Services. Amazon Services via XmlPull. Amazon Services via kDOM. A Mobile RSS Client. Summary. Resources.

16. SOAP Web Services on Smart Clients.

What Is SOAP Web Services? Introducing kSOAP. kSOAP Explained. Advanced kSOAP. More kSOAP Examples. What's in kSOAP v2.0? Summary. Resources.

17. The J2M 2ME Web Services Optional Package.

A Little History. The XML Processing API. The JAX-RPC API. The SPI for Implementers. Compare with kXML and kSOAP. Summary. Resources.

18. Case Study: Mobile Clients for Location on-Based Services.

Location-Based Service. Microsoft MapPoint Web Services. MapPoint J2ME Clients. Enhancing the Driving Directions Application. Summary. Resources.


19. Mobile Security for Enterprise.

What Is Advanced Mobile Security? Lightweight Mobile Cryptography Toolkits. Bouncy Castle Lightweight API. The IAIK ME JCE. Phaos Technology Micro Foundation Toolkit. NTRU jNeo for Java Toolkit. B3 Security. Device-Specific APIs. Standardization of J2ME Security APIs. Summary. Resources.

20. The J2M 2ME Crypto Recipes.

Overview of Recipes. Symmetric Encryption. Password-Based Encryption. Public Key Encryption. Digital Signature. Summary. Resources.

A: Basics of J2M 2ME Application on Development.

Life Cycle Methods. UI Model. Remote and Local Data. Code Walkthrough. Packaging and Building. Deployment. Summary.

B: Tools and J2M 2ME Runtimes for PDAs.

Overview of the WebSphere Studio Device Developer. Installing MIDP on PocketPC Devices. Installing Personal Profile on PocketPC Devices. Run Java Applications on the PocketPC Device. Summary.



Untitled Document

About this Book

Target Audience

This book targets all mobile software developers and business decision makers. It focuses on end-to-end architectural patterns, best practices, key innovations, and real-world design approaches. For different readers, this book offers different benefits:

  • Managers and entrepreneurs : This book is a comprehensive guide to mobile enterprise applications and the Java 2 Micro Edition (J2ME). It covers the capabilities, limitations, common best practices, and commercial solutions of the state-of-the-art mobile Java technologies. It helps you decide which mobile Java profile and products are the best for your business.
  • Experienced mobile developers : This book skips the basic MIDP API tutorial materials and goes straight to the more advanced and more useful topics. It uses several complete sample applications to illustrate common architectural patterns and coding best practices in mobile enterprise applications. For developers who are looking for specific solutions (e.g., messaging, database, XML, and security), the technical discussions on leading third-party J2ME tools and libraries will prove useful. Those real-world innovations also serve as prime examples of how you should design and implement your own solutions for similar tasks.
  • Experienced Java developers : For experienced Java enterprise developers (J2EE developers), the move to mobility is about leveraging existing skills. This book walks through familiar design patterns and best practices and shows developers how to apply them in mobile applications. Lightweight mobile versions of enterprise Java APIs (such as JDBC, Java servlet, JMS, and Java Cryptography Extension) are discussed. Those are excellent examples of how to scale down enterprise solutions for mobility while still preserving core functionalities. With a few notes on mobile-specific issues, it is the fastest path to add mobility to existing enterprise infrastructure.


To fully understand the technical content in this book, the readers should be familiar with the basic Java 2 Micro Edition, Mobile Information Device Profile (J2ME/MIDP) APIs and development tools. A quick MIDP programming guide is provided in Appendix A.

To run the end-to-end sample applications, you will need to deploy the serverside components to your own Java application server and run the clientside components on the desktop emulator or real devices. Please refer to the product manuals of your tools for step-by-step instructions.

Although serverside Java is not the focus of this book, familiarity with basic Java 2 Enterprise Edition (J2EE) concepts such as servlets, Java DataBase Connectivity (JDBC), Java Messaging Service (JMS), Java XML processing, and Enterprise JavaBean (EJB), will help you understand various topics in this book.


This book is divided into six parts:

  • Part I is the introductory material for mobile commerce, mobile enterprise applications, and J2ME. It covers the overall architecture, current status, and future roadmaps of J2ME.
  • Part II is the heart of this book. It presents several example applications to illustrate the smart client mobile application paradigm, common architectural patterns, and best practices. It covers how to run container-managed applications (e.g., servlets) on PDA devices. It also presents a useful advanced HTTP client library for J2ME clients.
  • Part III is about mobile messaging. In the mobile world, messaging clients are easy to use and fit into the mobile lifestyle. In the enterprise world, messaging is the best way to build loosely coupled applications that have guaranteed quality-of-service (QoS). This part of this book seeks to combine the best of the two worlds. It covers email and SMS-based end-to-end applications as well enterprise mobile messaging servers.
  • Part IV discusses mobile databases that are core to occasionally connected and synchronization-based applications. This part covers commercial and open source innovations for mobile databases, synchronization engines, and legacy database connectivity. Two sample database applications from PointBase are presented.
  • Part V covers how to integrate mobile clients into the enterprise Web services infrastructure. It discusses existing and emerging J2ME XML and SOAP toolkits, specifications and showcases several complete sample applications.
  • Part VI is all you need to know about J2ME mobile security solutions. It goes way beyond the simple connection-based end-to-end solutions such as the HTTPS. This part covers open source and commercial cryptography toolkits for J2ME. Due to the complexity of cryptography APIs, API tutorials for each important toolkit are provided.
  • There are two appendices to this book. One of them uses a simple end-to-end MIDP application to illustrate the whole development and deployment cycle. The other appendix introduces the IBM WebSphere Studio Device Developer IDE and provides undocumented instructions on how to install IBM J2ME runtimes on PocketPC devices.

Code Examples

This book uses complete example applications to demonstrate design patterns, best practices, and important API usages. Since this book discusses a wide range of technologies, innovations, and application scenarios, it is impractical to cover everything within a monolithic example. Instead, I decided to develop several small to midsize samples, each focusing on a particular topic. This approach allows the readers to partition the learning task and read one part of this book at a time.

The source code is presented in easy-to-digest segments that are relevant to the discussion text. Nonessential parts of the code (e.g., exception handling, importing packages) are often deliberately omitted from the listings for clarity. Hence, the printed listings are suffcient for understanding the ideas but are not directly runnable code.

  • iFeedBack : The grand prize winner of the NexTel/Motorola/Sun wireless application contest in 2002 (Chapter 3).
  • Echo : A GUI client and a service running in an OSGi clientside container (Chapter 4).
  • Pizza Order : An example included in the IBM Service Management Framework download. It demonstrates how to build smart clients with HTTP front ends (Chapter 4).
  • Smart Ticket : The Sun Wireless Blueprints application v2.0 early release code (Chapter 5).
  • HttpClient : The code for the advanced HTTP library we develop in this section (Chapter 6).
  • Mail : An MIDP email client based on the Mail4ME v1.0 library (Chapter 8).
  • WMATester : A simple messaging application that illustrates the use of Wireless Messaging API v1.0 (Chapter 9).
  • ContactManager : A mobile address book based on the PointBase v4.5 library (Chapter 11).
  • ContactManagerSync : A synchronized mobile address book based on the PointBase v4.5 library (Chapter 13).
  • AmazonExample : An kXML client for AmazonWeb services using both kDOM and XmlPull APIs (Chapter 15).
  • PeekAndPick : A RSS reader for mobile phones developed by Jonathan Knudsen (Chapter 15).
  • Google : A simple client for the Google Web services API. Both kSOAP v1.2 and v2.0 versions are available (Chapter 16).
  • SmartPhrases : An integrated Google search and online dictionary application (Chapter 16).
  • MapPoint AxisFacade : An Apache Axis facade for MapPoint v3.0 Web services (Chapter 18).
  • MapPoint AxisClient : Personal Profile and MIDP clients for the Map-Point facade (Chapter 18).
  • MobileSecurity : A collection of small applications that demonstrate the correct usage of cryptography APIs (Chapter 20).
  • SimpleDemo : A simple MIDP application to illustrate key concepts and APIs in MIDP programming (Appendix A).

Commercial Products

This book covers and compares more than 30 toolkits and libraries from more than a dozen third-party vendors. The descriptions and API usage examples of those products are intended to give the readers a solid technical ground to make informed comparisons and decisions. They also serve as realworld examples for API and tool designs. However, they do not substitute for the formal product documentation from the vendor. I strongly encourage interested readers to obtain the latest evaluation package and documentation from the vendor to investigate further.

Related Publications

Some of the materials used in this book are loosely based on articles I published previously on several online magazines.

  • The Sun Smart Ticket blueprint discussed in Chapter 5 is also covered in “End-to-End J2ME Application Development by Example,” published on the Sun Wireless Java Web site in June 2003.
  • The first half of Chapter 9 is also covered by “Mobile P2P messaging, Part 1,” published on IBM developerWorks in December 2002.
  • Examples in Part IV are adapted from “High-availability mobile applications,” published on JavaWorld in June 2003.
  • Chapter 16 is based on “Access Web services from wireless devices,” published on JavaWorld in August 2002.
  • The example in Chapter 18 is adapted from “Let the mobile games begin, Part 2,” published on JavaWorld in May 2003.
  • Part VI is loosely based on “Data security in mobile Java applications,” published on JavaWorld in December 2002.

Production Notes

This book is produced by the Latex typesetting system on a 1GHz Apple PowerBook running Mac OS X—the best consumer operating system ever produced. Microsoft Word is used for collaborative editing and reviewing. The figures are made with Microsoft Visio, OmniGra2e, GIMP, and the ImageMagick utilities.

The example applications are developed using a variety of development tools, including VI, JEdit, IntelliJ IDEA, and the WebSphere Studio Device Developer IDE. Apache Ant is used to build the applications. Mobile clients are tested on many vendor SDKs, including those from Sun Microsystems (the J2ME Wireless ToolKit), IBM (the WebSphere Micro Environment), Nokia, and Motorola. Real device testing was conducted on Motorola i95cl, Nokia 7210, Nokia 6800, and PocketPC Phone devices.


Download the Index file related to this title.


Submit Errata

More Information

Unlimited one-month access with your purchase
Free Safari Membership