Beginning Java Me Platform 1st Edition Ray Rischpater
Beginning Java Me Platform 1st Edition Ray Rischpater
Beginning Java Me Platform 1st Edition Ray Rischpater
Beginning Java Me Platform 1st Edition Ray Rischpater
Beginning Java Me Platform 1st Edition Ray Rischpater
1.
Beginning Java MePlatform 1st Edition Ray
Rischpater download
https://ebookbell.com/product/beginning-java-me-platform-1st-
edition-ray-rischpater-2421264
Explore and download more ebooks at ebookbell.com
2.
Here are somerecommended products that we believe you will be
interested in. You can click the link to download.
Beginning Java Objects From Concepts To Code 3rd Edition 3rd Jacquie
Barker
https://ebookbell.com/product/beginning-java-objects-from-concepts-to-
code-3rd-edition-3rd-jacquie-barker-48529190
Beginning Java Game Development With Libgdx Create A Great Variety Of
Games Quickly And Efficiently With Libgdx 1st Edition Lee Stemkoski
https://ebookbell.com/product/beginning-java-game-development-with-
libgdx-create-a-great-variety-of-games-quickly-and-efficiently-with-
libgdx-1st-edition-lee-stemkoski-50195884
Beginning Java 8 Fundamentals Language Syntax Arrays Data Types
Objects And Regular Expressions Kishori Sharan
https://ebookbell.com/product/beginning-java-8-fundamentals-language-
syntax-arrays-data-types-objects-and-regular-expressions-kishori-
sharan-53682904
Beginning Java 8 Apis Extensions And Libraries Swing Javafx Javascript
Jdbc And Network Programming Apis Sharan
https://ebookbell.com/product/beginning-java-8-apis-extensions-and-
libraries-swing-javafx-javascript-jdbc-and-network-programming-apis-
sharan-22004732
3.
Beginning Java Mvc10 Model View Controller Development To Build Web
Cloud And Microservices Applications 1st Ed Peter Spth
https://ebookbell.com/product/beginning-java-mvc-10-model-view-
controller-development-to-build-web-cloud-and-microservices-
applications-1st-ed-peter-spth-22474306
Beginning Java 7 1st Edition Jeff Friesen
https://ebookbell.com/product/beginning-java-7-1st-edition-jeff-
friesen-2376214
Beginning Java Se 6 Game Programming 3rd Edition Jonathan S Harbour
https://ebookbell.com/product/beginning-java-se-6-game-
programming-3rd-edition-jonathan-s-harbour-2417876
Beginning Java Game Programming Jonathan S Harbour
https://ebookbell.com/product/beginning-java-game-programming-
jonathan-s-harbour-2564296
Beginning Java 17 Fundamentals Objectoriented Programming In Java 17
3rd Ed Kishori Sharan
https://ebookbell.com/product/beginning-java-17-fundamentals-
objectoriented-programming-in-java-17-3rd-ed-kishori-sharan-36428050
About the Author
■RAYRISCHPATER is an engineer and
author with more than 15 years of expe-
rience writing about and developing for
mobile-computing platforms. During
this time, Ray has participated in the
development of Internet technologies
for Java ME, Qualcomm BREW, Palm OS,
Apple Newton, and General Magic’s
Magic Cap, as well as several proprietary
platforms. Presently, Ray is employed as
the chief architect at Rocket Mobile, a
wholly owned subsidiary of Buongiorno
Group. When not writing for or about mobile platforms, Ray enjoys hiking with his
family and participating in public service through amateur radio in and around the
San Lorenzo Valley in northern California. Ray holds a bachelor’s degree in pure mathe-
matics from the University of California, Santa Cruz and is a member of the Institute of
Electrical and Electronics Engineers (IEEE), the Association for Computing Machinery
(ACM), and the American Radio Relay League (ARRL). Ray’s previous books include
Software Development for the QUALCOMM BREW Platform (Apress, 2003), Wireless Web
Development, Second Edition (Apress, 2002), and eBay Application Development
(Apress, 2004).
xvii
20.
About the Technical
Reviewer
■CHRISKING has been writing software since childhood; today he focuses on the
challenges and joys of mobile development. In recent years, he has specialized in
technologies such as Java ME, Qualcomm BREW, and Android. His recent projects
include messaging software that has been preloaded on millions of phones, consumer
entertainment devices, middleware libraries, community organizing tools, and
lifestyle applications. Chris currently serves as a lead engineer for Gravity Mobile
in San Francisco.
Since moving to California, Chris has become an avid hiker, cyclist, and home cook.
With any free time that remains, Chris programs for fun, writes, and devours books.
xix
21.
Acknowledgments
Any book todayis the collaborative effort of numerous people; technical books such as
this one even more so. In helping me produce this book, I owe thanks to numerous peo-
ple, including some who don’t realize how much they helped, and others whose names I
may never know.
My son Jarod has been part of my writing career since it started; my first book and his
birth nearly coincided. He is now old enough that he is writing both prose and programs
on his own, giving us valuable opportunities to share in learning together. His respect for
the craft of writing—shown through his asking me questions about what I am doing and
how I do it—is precious to me. His ability to help me wholly forget the frustrations inher-
ent in any large project when he and I are together is just one of the many priceless gifts
he gives me.
My wife Meg embraced and encouraged this project from the beginning, despite
knowing it would mean that I would spend countless hours apart from her as I researched
and wrote the examples and text for this book. Her patience with my absence—extending
to when I was physically present yet mumbling about some minutia of mobile-application
development—bordered on the heroic at times. I cherish our relationship, and it moves
me to reflect how each of us supports the other to grow and succeed.
The entire Apress staff was indispensible in bringing this book to you. Steve Anglin and
Richard Dal Porto were crucial in helping start the project and shepherd it to completion.
Richard was especially helpful in keeping all of the different parts of production running
smoothly, even when I found myself missing the occasional deadline. Nicole Abramowitz,
my copy editor, was both thorough and patient, and made innumerable improvements to
this book. Katie Stence, my production editor, made the production review process pain-
less as I saw how the book would appear in print for the first time. I also must thank those
at Apress whom I have not met personally, because without their contributions, Apress
would not be the successful company with which I find it so easy to work.
Chris King, this book’s technical editor, is also my colleague and friend. His attention
to detail frequently transcended errors of program syntax and improved my exposition of
many of the concepts you encounter in this book. He fearlessly ran—and read—every
example in this book and helped improve even the pseudocode that I use in many places
as examples. I have always enjoyed working with Chris professionally, and this project
cements my professional respect for him.
xxi
22.
My colleagues atRocket Mobile (now part of Buongiorno Group) deserve recognition
not only for providing additional Java ME experience on which to draw for several exam-
ples in the book, but also for their patience and support. I must apologize to Erik Browne,
Levon Dolbakian, Graham Darcy, Jonathan Jackson, and Rajiv Ramanasankaran for
enduring my frequent C and Java transpositions as I wrote C code for the office during
the day and Java code for the book at night. The management staff—including Young
Yoon, Scott Sumner, Jim Alisago, and Wayne Yurtin—has given me the privilege of com-
bining software engineering and writing, and has provided a climate in which both can
succeed. Thank you, each and every one of you.
Many people close to me contributed additional support, whether or not they knew
they were doing so. Brad Holden, Connie Rockosi, Chris Haseman, and Shane Conder are
at the top of this list for giving me much-needed space, time to work, and positive
encouragement during the many times when I wondered if it were possible to write a
book while working full-time and having an active life outside my technical career. I am
indebted to these and others for their contributions as well.
■ACKNOWLEDGMENTS
xxii
23.
Introduction
When I setout to write this book, I was often surprised by the comments I received
from friends and colleagues. Many asked me if some other platform, such as Android
or the iPhone, would render Java Platform, Micro Edition (Java ME) obsolete (and non-
existent, some posited) by the time the book is published. Still others pointed to the
growing convergence between different lines of Java as rendering the need for separate
information about Java ME obsolete. And a few remarked scathingly that the market
for Java books was saturated, so investing the time to write another was an exercise in
futility. You, too, may ask these questions as you decide whether or not to read this book.
Perhaps you’re interested in Java ME as a specific platform on which to deploy an exist-
ing product, or perhaps you’re just curious as to whether you should include Java ME
skills in your professional portfolio.
The Java ME platform is a highly successful one. Billions—yes, that’s with a b—of
devices that run Java ME are in the hands of consumers right now. Still more are on the
way, including mobile phones, set-top boxes, and other devices you can’t even imagine
that are now in development. Java ME is deeply entrenched in the market, and yet
through the Java Community Process (JCP), it evolves rapidly to address challenges
raised by existing and new competing platforms, including Qualcomm BREW, Android,
and the Apple iPhone.
The cross-pollination between Java ME, Java Platform, Standard Edition (Java SE),
and Java Platform, Enterprise Edition (Java EE) is well recognized and will continue.
Members of the JCP work carefully to introduce APIs that can be shared across these Java
platforms, and many Java ME APIs are subsets of APIs proposed or developed for Java SE.
In some cases, the opposite is true: Java ME APIs are being introduced into Java SE, such
as the Java ME framework for communications and networking. As devices become more
capable, you will see more convergence between the various Java lines, but the specific
constraints on mobile devices—including ubiquitous network access, a small form fac-
tor, and scarce power, memory, and processor resources—will drive the need for specific
accommodations within the Java platform. Java ME and the JCP provide a framework for
vendors to make those accommodations.
There are many excellent books about Java 2 Platform, Micro Edition (J2ME)—the
predecessor to Java ME—and several good books about facets of Java ME as well. How-
ever, the Java ME platform evolves and advances at a truly awe-inspiring rate, and this
fact and the sheer size of Java ME make it difficult to find a good book for beginners that
provides a broad foundation on which to build Java ME competency. In this book, I’ve
worked to balance the presentation of the two profiles that comprise Java ME, because I
xxiii
24.
believe that foryou to be successful, you need to understand both. At the same time, I’ve
made explicit choices about the required and optional Java ME APIs I present, because I
believe that in building this foundation, you need to understand some basic principles
that arise again and again in the Java ME world, but you don’t necessarily need to be able
to recall from memory every method from every optional Java ME class. Given the time
you have, I believe it is important for you to master the platform fundamentals, so that
you’re better equipped to specialize in the areas that interest you later. In short, what I
don’t present here may be as important to you as what I do present.
Why Should You Read This Book?
I’ve already partially answered this question, but it’s worth recapping: Java ME is an inte-
gral part of the mobile-computing marketplace, and it’s a platform that every software
developer who works with mobile devices should be familiar with. Whether you need to
use it daily in your job, see it as competition, or are simply curious about how it’s differ-
ent from the platforms for which you presently develop applications, understanding Java
ME fundamentals will make you a better mobile software developer.
Whether you’re new to mobile-application development or have written mobile
applications for other platforms and are interested in learning what you need to know to
be a Java ME developer, you should read this book. By turning equal attention to the two
Java ME configurations—the Connected Limited Device Configuration (CLDC) and the
Connected Device Configuration (CDC)—I prepare you to write software for either the
booming mobile-phone market or the nascent market for set-top boxes and high-end
mobile phones with advanced user interfaces and other capabilities. Because Java ME
devices at their core are network-enabled devices, I spend a great deal of time explaining
to you the APIs that Java ME uses to enable applications to communicate, and I prepare
you to understand new communication schemes that Java ME may use in the coming
years. Once you finish this book, you can expect to have a grasp of the most important
APIs that Java ME developers use, as well as an understanding of the fundamental think-
ing behind the design and approach of the Java ME platform and the dynamics of the
mobile-software marketplace as a whole.
However, I have some expectations of you as well. I assume you have at least some
previous exposure to Java SE—both the language and some of the major classes that it
supports. You may not know the difference between a HashMap and a TreeMap, but you
should at least have a nodding acquaintance with Java syntax, the Java package system,
and some of the basic foundation classes that you can find in the java.lang and java.util
packages. Because it’s an important communication tool, you should also have at least a
nodding acquaintance with Unified Modeling Language (UML), as I frequently use UML
class, state machine, and sequence diagrams to help illustrate the relationship between
various Java ME components.
■INTRODUCTION
xxiv
25.
Don’t worry, though,if you’re new to mobile-software development. One primary
aim of this book is to help you understand the dynamics of the mobile software–
development marketplace, because those dynamics have and continue to influence
Java ME. I firmly believe that a good software developer understands not just the plat-
form, but the business behind the market as well. I also don’t expect you to be a Java
expert: you can write solid code clearly using a minimum of Java-specific language fea-
tures. If I throw a closure or anonymous inner class your way, I’ll let you know; my goal
here is for you to learn to write mobile applications, not become the office Java guru.
In the interest of full disclosure, there may be reasons why this book isn’t for you. I
don’t discuss every optional Java ME API in detail—for example, I omit discussions of
both the Java Mobile 3D Graphics API and Java ME support for Bluetooth—because
they’re well covered by other texts and because they’re not necessary material that every
Java ME developer must know. In a similar vein, if you already have a great deal of Java
ME experience under your belt, you may still learn something from this book, but your
time may be better spent with a more in-depth exploration of a specific set of optional
APIs that interest you. For example, another source, such as a Java Specification Request
(JSR) that describes a particular API or a book on a specific topic, may be better for you. I
intend this book to be a survey for beginners new to the platform that calls out the rules
of the road and relevant landmarks, not an atlas of every intersection, hilltop, creek,
island, and bay.
How Should You Read This Book?
Presenting Java ME to newcomers poses particular challenges, because in many ways,
Java ME is really two platforms: one that’s wildly successful for mobile phones, and a
second that’s deployed in other consumer-electronics markets. As an engineer myself, I
recognize how busy you are and how you may be looking to me to give you only the infor-
mation you need to solve a set of problems on a specific platform, such as a set-top box
running the Java ME CDC. Consequently, I’ve split this book into five parts, so that you
can pick and choose the information that’s relevant to you.
• Part 1,“Getting Started”: Exposes you to the information that every Java ME devel-
oper should know: how Java ME is organized, which APIs are common across all
Java ME platforms, and which tools are available. I strongly recommend you read
the three chapters in this part to orient yourself to the Java ME market and mindset.
• Part 2,“CLDC Development with MIDP”: Explores the Java ME Connected Limited
Device Configuration (CLDC) and Mobile Information Device Profile (MIDP) in
detail. This configuration and associated profile comprise the most widely
deployed mobile-application platform in the world, and if you’re interested in
writing software for mobile phones or other wireless terminals, you’ll need to have
a good grasp of what it offers.
■INTRODUCTION xxv
26.
• Part 3,“CDCDevelopment”: Explores the Java ME Connected Device Configuration
(CDC), which underpins many consumer devices today, including television set-top
boxes and some advanced mobile phones. The CDC even plays a part in the Blu-ray
Disc standard. The information you’ll find here is often overlooked in other intro-
ductory Java ME materials, but it plays an increasing role in Java ME development.
• Part 4,“Communicating with the Rest of the World”: Explains how Java ME enables
the applications that you write to communicate with the rest of the Web. You’ll
learn about the Generic Connection Framework (GCF)—a key addition to the Java
world—as well as how Java ME enables you to work with both Internet protocols
and wireless-messaging protocols.
• Part 5,“Other Java ME Interfaces”: Shows you a few optional APIs that every Java
ME developer should know about. These interfaces are important for you to
understand both because they provide capabilities nearly every application will
tap (such as security and trust interfaces), and because the interfaces provide a
fundamental framework that other optional Java APIs extend (such as the Mobile
Media API). This part closes with a chapter examining how optional APIs frag-
ment the Java ME platform and how the Java community works together to
address this fragmentation.
A short “Intermezzo” precedes each part, helping orient you in the book.
Eighteen chapters await you in the five parts:
• Chapter 1,“Mapping the Java Jungle”: Introduces some key vocabulary and busi-
ness concepts you must understand before becoming a Java ME developer.
• Chapter 2,“Shrinking Java to Fit”: Describes the key transformation Java under-
goes between Java SE and Java ME. If you’re a seasoned Java SE developer, you
should read this chapter closely, as it tells you which language features and
classes you already know that are available to you in Java ME. If you’re fairly new
to Java, you should skim this chapter, but don’t be worried if you have to flip back
to it occasionally.
• Chapter 3,“Getting Started with the NetBeans IDE”: Enables you to build your first
Java ME applications using the leading software development kit (SDK) for Java ME
development. You’ll learn why NetBeans is the environment of choice for develop-
ing Java ME applications, and you’ll learn how to build two simple applications
from scratch using NetBeans. These sample applications are the starting points for
many of the examples in subsequent chapters. Even if you decide later to switch to
another SDK, this chapter will help you understand how the development tools for
Java ME fit together. In the process, you’ll also get a quick overview of the major
features of Java ME as you build these simple applications.
■INTRODUCTION
xxvi
27.
• Chapter 4,“IntroducingMIDlets”: Begins your exploration of one of the software
world’s most successful application platforms. You’ll learn about the MIDlet, which
is the unit of application execution on most Java ME devices.
• Chapter 5,“Building User Interfaces”: Describes the hierarchy of user-interface
components that are available only to Java ME developers. You’ll learn how the Java
ME–provided components work and interact, as well as how to extend the Java ME
component hierarchy.
• Chapter 6,“Storing Data Using the Record Store”: Describes the Java ME record-
store model that your applications can use for persistent storage. The record store
is available even on devices without a traditional file system, and it gives you the
ability to store records of similar data in a searchable, persistent manner.
• Chapter 7,“Accessing Files and Other Data”: Provides your first exposure to an
optional Java ME API—that is, an API that may not be available on all platforms. It
is such an important API, however, that it’s one you should master early. You’ll
need to understand how it and the record-store model presented in the previous
chapter work.
• Chapter 8,“Using the Java Mobile Game API”: Describes the Java Mobile Game API
and shows you how to write simple platform-independent games using Java ME.
Game development is a complex subject; rather than get bogged down in details
about game development that may not interest some readers, I emphasize the fun-
damentals of Java ME as they interrelate with game-development concerns.
• Chapter 9,“Introducing Xlets and the Personal Basis Profile”: Describes the parts of
Java ME that to date have largely applied to fixed consumer electronics, such as
set-top boxes. You’ll learn about the application model these devices support, as
well as the interfaces they offer.
• Chapter 10,“Introducing Applets and the Advanced Graphics and User Interface”:
Describes additional execution models available on Java ME platforms, plus sup-
port for legacy Java applets and an adaptation of Swing available on some Java ME
devices.
• Chapter 11,“Using Remote Method Invocation”: Shows you how some Java ME
devices can use Remote Method Invocation (RMI) to interact with other Java-
provided services on the network.
• Chapter 12,“Accessing Remote Data on the Network”: Begins your foray into the
communication framework supported by all Java ME devices, and shows you how
to use it with Internet protocols to access data and services over the network.
■INTRODUCTION xxvii
28.
• Chapter 13,“AccessingWeb Services”: Builds on what you learn in Chapter 12 to
show you how Java ME’s optional APIs and open source packages enable your
applications to access web services using Extensible Markup Language (XML)
and HTTP
.
• Chapter 14,“Messaging with the Wireless Messaging API”: Shows you how to use the
wireless messaging interfaces available on many Java ME devices. These interfaces
enable you to send and receive messages with protocols such as Short Message
Service (SMS).
• Chapter 15,“Securing Java ME Applications”: Looks at optional Java ME interfaces
that provide extensions such as cryptography and access to smart cards, as well as
interfaces that enable mobile commerce, such as the optional API for reading
radio-frequency identification (RFID) cards and bar codes.
• Chapter 16,“Rendering Multimedia Content”: Describes Java ME’s approach to
providing support for multimedia content rendering. I show you both the Mobile
Media API that Java ME devices may provide, as well as an optional API for display-
ing and animating Scalable Vector Graphics (SVG) images.
• Chapter 17,“Finding Your Way”: Describes the optional Java ME interfaces that let
your application determine the device location.
• Chapter 18,“Seeking a Common Platform”: Closes the book with a discussion of
how the optional APIs that Java ME devices may provide challenge application
developers like you to find sufficient devices that provide the features your appli-
cations require. I also explain how the Java community is addressing that challenge
through additional device profiles such as the Java Technology for the Wireless
Industry and Mobile Service Architecture (MSA).
• Appendix,“Finding Java APIs”: Provides you with a table of interesting mobile tech-
nologies and the JSRs that define support for those technologies. When you’re
finished reading this book and want to learn more about a specific technology and
how it interacts with Java ME, you can use this table to determine where to start
your research.
Ideally, I’d encourage you to read all of Parts 1–4 and then whatever parts of Part 5
interest you, especially if this is your first exposure to Java ME. However, you can tackle
this material in other ways as well. If you’re interested in a specific Java ME configuration,
you can first read Part 1, then either Part 2 or Part 3, and then Part 4 and parts of Part 5,
for example. Regardless, because some material requires you to master the material that
precedes it, you should read material earlier in the book even if you skip around before
you dive in to material that comes later in the book.
■INTRODUCTION
xxviii
29.
How Do YouGet Started?
Of course, sample applications in this book are all available electronically at the Apress
web site, http://www.apress.com. Begin by reading Chapters 1 and 2, and then download
the NetBeans SDK at http://www.netbeans.org; if you’re really in a hurry, download the
SDK now and work through Chapter 3, so you can get a feel for what Java ME application
development is all about.
I encourage you to build on what you learn here by consulting other sources; one
excellent source is the Java Community Process web site at http://www.jcp.org, where
you can find the JSRs that describe the Java ME platform (and other Java platforms and
extensions to Java platforms as well). If you prefer working on the bleeding edge, the wiki
for NetBeans at http://wiki.netbeans.org is another excellent resource, especially if you
find yourself enamored with the NetBeans environment. Finally, I’ll make more resources
available as necessary on my web site at http://www.lothlorien.com.
■INTRODUCTION xxix
30.
Getting Started
Before youbegin writing code for Java Platform, Micro Edition (Java ME), you should
have a good grip on the fundamentals. That’s what this part is all about: helping you get a
handle on why Java ME is relevant, how to start out writing code for Java ME using Net-
Beans, and how Java ME differs from traditional Java programming.
P A R T 1
31.
Mapping the JavaJungle
Although at its heart Java ME is really just an adaptation of the Java language, class
libraries, and concepts to fit constrained devices, the business behind Java ME is in fact
quite different. A firm grasp of the Java ME market, platform, and terminology will put
you in good stead to developing successful products using Java ME.
In this chapter, I begin by introducing the market for Java ME. Next, I take you on a
tour of the Java ME platform, showing you how Sun identified and defined the basic
requirements for mobile platforms, and how manufacturers, carriers, and others have
extended this basic platform. Finally, I discuss how the process of application develop-
ment for Java ME is different, and I show you how important it is to know your audience,
target devices, and distribution channel.
After reading this chapter, you will understand why Java ME differs from Java. You
will see how device manufacturers, wireless operators, and consumers view Java ME, and
how Java ME meets the needs of all of these parties. Armed with this knowledge, you’ll be
able to better manage a Java ME development project.
Introducing the Market for Java ME
A trio of forces dominates the Java ME market: device manufacturers looking to differenti-
ate their products in the marketplace, wireless operators seeking to differentiate services
and raise the average revenue per user (ARPU), and consumers personalizing their
devices in new and novel ways.
Looking from the Device Manufacturers’ Perspective
The interplay between device manufacturers and wireless operators is complex. Manu-
facturers are in constant competition with each other to differentiate their products,
while at the same time, in many markets they are beholden to wireless operators to meet
stringent requirements for features and functionality.
Device manufacturers can be broadly separated into two categories: original equip-
ment manufacturers (OEMs) and original design manufacturers (ODMs). OEMs build
3
C H A P T E R 1
32.
devices under theirown label and sell devices to consumers (either directly or via the
operator, or most often both), while ODMs design and build hardware on behalf of oth-
ers. While both ODMs and OEMs must differentiate their product on the basis of price,
quality, and features, for OEMs brand and marketing also become key concerns.
Many of today’s wireless operators simply require a Java ME runtime on most of the
phones that they provide to subscribers. As I discuss in the next section, “Looking from
the Operators’ Perspective,” operators are seeking ways to raise revenue per subscriber,
and data services are one way to do this. Today, data services consist of more than just
wireless web services; many Java ME applications rely on the network for their content.
Requiring handset manufacturers to include Java ME on their devices leaves an open
door for developers to create new applications that provide operators with new sources
of revenue.
Providing Java ME on devices is more than just an operator requirement for many
manufacturers. Some manufacturers, including Research In Motion (RIM), offer Java
ME runtimes that both meet Java ME standards as well as include additional classes in
their implementation, enabling developers to build novel applications atop the phone’s
fundamental platform. More frequently, however, you’ll find the baseline Java ME
implementation on a device. In either case, Java ME enables device manufacturers to
build and bundle applications for their products more quickly than with existing
embedded toolkits.
This is especially true for the growing number of dedicated devices that connect via
home or municipal wired and wireless networks where the use of Java ME may not be a
mandate. Java ME provides a ready alternative to closed, proprietary platforms for writing
application software for wireless Internet devices, set-top boxes, and other embedded sys-
tems. Even when the end platform is closed to third-party developers, selecting Java ME
can help device manufacturers bring their product to market by providing a more powerful
and well-understood platform than an internally defined or purely embedded alternative.
Whether chosen because of a customer requirement, as an opportunity for differen-
tiation, or to speed product development, Java ME provides important advantages over
other platforms. Unlike its larger cousins, Java Platform, Standard Edition (Java SE) and
Java Platform, Enterprise Edition (Java EE), Java ME has been carefully tuned to run on
small devices, important for meeting the cost and power constraints of most devices
today. It’s an open platform, encouraging contributions of technologies through the Java
Community Process (JCP). Finally, Java ME brings with it the entire community of Java
developers, providing a pool of talented engineers, designers, and project managers from
which to draw.
Looking from the Operators’ Perspective
Wireless operators today face challenges, too. While differentiation on the basis of quality
and brand remain important, chief among challenges is the drive for higher ARPU. Rev-
enue from voice activity has largely leveled off, making data services an obvious area in
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
4
33.
which to drivegrowth. This is especially true in some countries, including the United
States, where carriers have spent huge sums of money obtaining the rights to new parts
of the wireless spectrum.
While arguably the wireless Web, Short Message Service (SMS), and Multimedia
Messaging Service (MMS) all play a role in contributing to the bottom line for data serv-
ices, mobile applications play a growing role as well. Java ME applications can contribute
in two ways: by driving data use itself and by providing revenue when an operator acts as
the channel for application distribution. Increasingly, just as you can buy a ring tone or
wallpaper for your handset via the operator’s wireless web portal, you can now buy Java
ME applications as well. As you will learn later in this chapter (in “Marketing and Selling
Your Application”), partnerships between developers and operators establish important
channels for application sales, bringing revenue to both parties.
While the bottom line drives business decisions, marketing and brand image play an
increasing role in Java ME’s importance for operators. By opening their network to third-
party developers such as yourself, operators bring your creativity to the table. Moreover,
Java ME enables operators additional ways to partner with key brands around the globe,
helping the operators differentiate themselves and giving brands far removed from the
mobile computing market an opportunity to interact with consumers in new ways.
Looking from the Consumers’ Perspective
Today’s consumers demand more from their devices. Whether using a cell phone, set-top
box, or dedicated appliance, consumers expect clear value. Reliability, ease of use, per-
sonalization, and network awareness are features becoming increasingly important even
for traditionally isolated devices. Java ME fits the bill as a platform on which to base these
devices, because it’s small, highly portable, and powerful.
In the wireless telecommunications market, consumer demand for reliability, ease of
use, personalization, and network awareness has already begun and continues to grow.
As I write this, Sun estimates that more than two billion wireless terminals have shipped
with a Java runtime since the initial launch of Java for handsets. These devices support
communication, entertainment, multimedia, and other applications bringing customiza-
tion and choice to mobile device users around the world.
Java is poised to repeat this success within the set-top box market after years of
persistent effort. With Java on every Blu-ray player as well as countless set-top boxes
for personal entertainment, the potential for new applications is almost boundless. This
market will be more diverse than the mobile market, with room for both small players
and large application development houses as well as the traditional entertainment
content partners (many of whom were latecomers to the wireless telecommunications
marketplace).
Through all of this, Java ME enables developers to provide subscribers with greater
choice, freedom, and flexibility. The fundamental platform enables developers to create
stand-alone applications as well as network-aware applications and games, while
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 5
34.
enabling manufacturers toadd more interfaces to tap the custom features of the
underlying platform.
Some pundits have accused the Java ME marketplace of “wagging the dog” to some
extent—that is, driving consumer demand for applications for the sake of technology itself.
While this claim is not wholly unwarranted, it’s also the nature of a fast-paced market in
which new products are tested on the market, and only those with successful business
cases and clear value to consumers will survive. Java ME accelerates this process by provid-
ing an open standard on which to base the development of new products and services.
Looking Inside the Java ME Platform
The Java ME platform isn’t really one platform, but rather a collection of platforms and
libraries that work on a host of mobile devices. Even more confusing, Java ME began as a
mobile environment for cell phones and personal digital assistants (PDAs), but has since
expanded to include devices with similar constraints, including industrial devices, set-
top boxes, Internet appliances, and other constrained platforms.
Justifying the Need for a Mobile Edition of Java
At first, the need for a mobile edition of Java may not be apparent. After all, today’s cell
phones are more powerful than the PCs that ran the first commercially available ver-
sions of Java more than a decade ago. However, a key feature of Java ME is its size and
performance footprint. This is especially important for the constraints common to
mobile and embedded devices. The constraints that mobility puts on size, power con-
sumption, and cost mean that less capable processors and less memory will be found in
devices for the foreseeable future. These constraints apply to less-mobile devices such
as set-top boxes, too; in designing a commodity consumer device, every penny counts,
so frequently low-cost (slower) processors and less memory are available. Moreover, as
green manufacturing increasingly comes into play, fixed consumer devices will be sub-
ject to the same sorts of power constraints as mobile devices.
But Java ME isn’t just about footprint. It’s also about a new way of looking at comput-
ing. Many of the differences between Java SE and Java ME are about functionality, not
footprint. The Java Application Descriptor (JAD) file is one example; it describes an appli-
cation, including its name, icon, publisher, and other information. Or take Java ME’s
security model, which includes the notion of privileges and permissions for interfaces.
Using Java ME, running applications may require individual privileges to perform sensi-
tive operations, such as sending an SMS message, requesting the position of the handset
via the location-based interface, or exchanging data using Bluetooth. Privileges are speci-
fied in the JAD file of a Java ME application and may be granted or denied depending on
the origin of the application. (I discuss this in more detail in the “Packaging and Execut-
ing CLDC/MIDP Applications” section in Chapter 3.)
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
6
35.
It’s important torealize that the ultimate goal for Java ME is to provide an extensi-
ble yet highly portable, minimum-footprint, Java implementation that can run on a
wide variety of network devices with constant or intermittent network connectivity.
The platform emphasis is on application-level, not system-level, programming, and
the application programming interfaces (APIs) that are supported reflect this distinc-
tion. Extensibility is another distinction, especially for one flavor of Java ME: the
Connected Limited Device Configuration, which I discuss in the “Introducing
the Connected Limited Device Configuration” section later in this chapter. Extensibility
is a key differentiator between the platform, other Java platforms, and other computing
platforms as a whole.
Making Java Work on Mobile Devices
Chapter 2 looks at the changes made to Java and its base classes for Java ME in close
detail, but it’s worth summarizing these changes now:
• The Java runtime must have the ability to reject invalid Java class files to ensure
system security and integrity.
• The Java runtime controls an application’s access to specific parts of the system
(such as the file system, network access, and so forth).
• Applications run within a sandbox that prevents unauthorized access to other
applications and libraries.
• The environment must support the ability to download new applications, but
cannot use this mechanism to modify or override protected system classes in any
way (including changing the order in which classes are looked up).
• The platform libraries may lack specific interfaces for performance and memory
use reasons; for example, one configuration of Java ME doesn’t support object
finalization, nor does it have support for the Java Abstract Window Toolkit (AWT)
or Swing user-interface libraries.
• The platform may or may not have support for floating-point mathematical
operations, depending on the version.
For brevity, I’ve painted this list with a broad brush; not all of these changes apply to
all flavors of Java in the Java ME family, as you’ll learn in the next section and Chapter 2.
Because of the immense variety in devices supported by Java ME, there are actually
different implementations of Java for different devices. Specifically, how Java ME func-
tionality is defined for a specific device is based on three concepts:
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 7
36.
• Configuration: Definesthe basic set of libraries and Java virtual machine (VM) for
a broad range of devices
• Profile: Defines a set of APIs for a narrower range of devices
• Package: A set of optional APIs that pertain to a specific technology, such as
multimedia or Bluetooth access
Figure 1-1 shows how these abstractions stack to define the software characteristics
of a device.
Figure 1-1. The relationship between configurations, profiles, and packages in Java ME
Each instance of a configuration, profile, or package should have as its basis one or
more Java Specification Requests (JSRs) that document the purpose and interface for the
Java extension in question. Appendix A summarizes the JSRs relevant to Java ME that
define functionality discussed in this book.
Today, there are two configurations within Java ME: the Connected Limited Device
Configuration (CLDC) and the Connected Device Configuration (CDC). There are a
handful of profiles that sit atop either of these configurations, and many, many pack-
ages. (In the next section, I explore these configurations in greater detail.)
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
8
37.
The most commonlyknown tuple of configuration, profile, and package is based
on the CLDC package, including the Mobile Information Device Profile (MIDP) accom-
panied by optional packages, powering billions of the world’s mobile phones today. In
fact, this configuration is so common that many think of it as the only version of Java ME.
Figure 1-2 shows a typical mobile-phone configuration with a few common optional
packages. I discuss the MIDP in depth in the “Introducing the Mobile Information Device
Profile” section later in this chapter.
Figure 1-2. The relationship between configurations, profiles, and a few of the packages in a
typical cell phone
Another, increasingly common tuple is based on the CDC package and powers
set-top boxes and other devices. Such a digital media configuration is for higher-end
connected devices, and it incorporates the Foundation Profile as well as the Personal
Profile, and perhaps additional optional packages. Unlike the CLDC-MIDP configuration,
this configuration defines a subset of the Java AWT, bringing a well-understood graphics
library to mobile devices. Figure 1-3 shows a typical configuration based on the CDC for
today’s consumer electronics devices.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 9
38.
Figure 1-3. Therelationship between configurations, profiles, and packages in a typical set-
top box or other digial media hardware
Understanding Configurations
The fundamental building block of the Java ME architecture is the configuration.
A configuration defines the Java Virtual Machine (JVM), basic language support, and
fundamental classes for the widest possible set of devices, such as all mobile wireless
terminals or all set top box–like devices. A specific device must meet the requirements
of at least one configuration, such as the CLDC, in order to qualify as a Java ME device.
Introducing the Connected Limited Device Configuration
The CLDC is explicitly designed for memory-constrained devices that may be always or
intermittently connected to the network. It defines a Java environment based on the Java
K virtual machine (KVM), a modified version of the JVM that has been specially tuned to
operate on low-power devices with a 16- or 32-bit processor and as little as 192KB of
RAM. The most common deployment of the CLDC, as I’ve already noted, is in the billions
of Java-enabled cell phones that have shipped in the last several years.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
10
39.
A device withthe CLDC is quite primitive; it’s missing many of the classes you’d
expect to find that permit application development (such as user-interface widgets,
network connectivity, and the like). Instead, the implementation leaves those details
to profiles atop the CLDC, and focuses instead on reducing memory and CPU foot-
print to the absolute minimum necessary for the Java environment. One area
obviously affected is the nature of the libraries included in the CLDC; many Java SE
classes are simply not available in the CLDC, and of those that are available, not all
methods may be available. This is especially true for collections, where only three
classes and one interface are available. (For more details on exactly what is supported,
see Chapter 2.)
While the JVM historically absorbs the entire burden of Java bytecode verification,
this is not the case for the CLDC. Because bytecode verification is expensive both in
terms of processor and memory, the responsibility of bytecode verification is shared
between the developer and the KVM running on the mobile device. As part of the build
process, you run a tool called preverify that inlines subroutines in each class file (remov-
ing certain bytecodes in the process) and adds information about variables on the stack
and their types. At runtime, the KVM uses this additional information to complete the
bytecode verification prior to execution.
■
Note Two-pass preverification obviously brings with it potential security issues, because a malicious
developer could inject code that appears to be preverified but does not meet all of the standards required by
the CLDC. To address this, CLDC applications are typically downloaded from trusted sources; moreover, the
profile used with the CLDC—the MIDP—adds code signing, so that a Java implementation can verify the
originator of the code being executed and provide an appropriate level of trust.
But security changes don’t end there. The sandbox model, familiar to applet
developers from the early days of Java, plays a much greater role in the CLDC, where
applications are sandboxed from each other as well as the host operating system. Each
application runs in an environment where the only facilities it can access are those
classes in its own distribution and the local classes provided by the device’s configura-
tion, profile, and optional packages. The download, installation, and management of
other Java applications are also inaccessible, preventing one application from affecting
another. Finally, there is no facility for creating native methods, closing potential holes
between the sandbox and the native platform.
Another key feature of the CLDC is the Generic Connection Framework (GCF),
which defines a hierarchy of interfaces that generalize port connections. The resulting
hierarchy provides a single set of classes you use to connect to any network or remote
port, including Transmission Control Protocol over IP (TCP/IP), User Datagram
Protocol (UDP), and serial ports, just to name a few. The GCF is defined in the
javax.microedition.io package.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 11
40.
Due to processorand power constraints, CLDC 1.0 did not support floating-point
mathematics; CLDC 1.0 devices could only perform integer math. This changed with
the advent of CLDC 1.1, as CLDC 1.1 devices must support floating-point operations.
However, as a developer, you should be aware that floating-point mathematics remains
computationally expensive. Be careful when choosing to use them, as they can cause
performance issues within your applications.
Introducing the Connected Device Configuration
The CDC is for devices that are more capable than those used by the CLDC, such as
high-end PDAs, set-top boxes, and other Internet appliances. As such, the goals of the
CDC are slightly different than those of the CLDC. Instead of targeting the largest possi-
ble number of low-cost hardware, the CDC focuses on leveraging developer and
technology skills from the existing Java SE platform while respecting the needs of
resource-constrained devices.
Unlike the CLDC, the CDC virtual machine meets the same requirements as the JVM
that powers Java SE. In fact, if you add to the CDC the profile and packages usually found
on a media-capable device, you’ll find little that distinguishes the environment from a
Java SE platform except the extra APIs that additional packages may provide. This is the
strength of Java, and especially the more robust CDC: you can leverage your Java skills
across the entire product family line. In addition, the CDC includes all of the Java lan-
guage APIs required of the CLDC, including the GCF.
Packages containing classes defined by the CDC include java.lang, java.io, java.net,
java.security, java.text, and java.util. Devices running the CDC must also support
CLDC APIs and packages; this enables the fullest possible support for all Java applica-
tions. While such devices are rare on the market today, it’s an obvious future direction for
Java, as the majority of devices continue to become more and more powerful.
Understanding Profiles
Profiles collect essential APIs for building the most fundamental of applications across
a family of devices. The most well known profile by far is the MIDP, which powers
mobile phones and sits atop the CLDC. Equally important is the Foundation Profile,
which is analogous to the MIDP for providing application support classes. Unlike
CLDC-based devices, however, CDC-based devices typically also include either the
Personal Basis Profile or the Personal Profile, or both, to provide user-interface support
for applications.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
12
41.
Introducing the MobileInformation Device Profile
The MIDP is the foundation of today’s mobile-phone Java revolution (Part 2 of this book
is dedicated to the MIDP). Defining a number of new interfaces, it enables you to develop
MIDlets, which are applications that run atop the CLDC. The MIDP defines these other
interfaces, as well:
• The application life cycle via the MIDlet
• Networking
• Persistent storage
• Sound
• Timers
• The user interface (including the portable display and input as well as support for
games)
However, the MIDP defines more than just interfaces and the classes that support
those interfaces. It also describes how applications are installed on a device. While the
actual implementation may differ from device to device, the general requirement is that
from the device you’re able to browse applications, select one for download using
HTTP/1.1, and have the device install the MIDP and present it in its application manager.
Applications are accompanied by an application descriptor (see the “Packaging and Exe-
cuting CLDC/MIDP Applications” section in Chapter 3) that includes information about
the application, such as the application vendor, application name, and application size.
The MIDP defines the notion of permissions, which indicate that a MIDlet can
access a restricted API. The only permission defined by the MIDP pertains to network
connections, but packages are free to introduce other permissions. A permission is a
name using the same prefix and class or interface name as the name of the restricted
API. For example, to use a network socket, a MIDlet needs the permission javax.
microedition.io.Connector.socket. This permission accompanies the application in the
descriptor file, and a MIDlet can test for the presence of a privilege using the MIDlet
method checkPermission, which returns 1 if the permission is granted, 0 if it is not, and
–1 if the result is indeterminate, such as a requirement that the user be asked to grant
permission manually.
The MIDP also defines the notion of a trusted application, which is permitted to use
a restricted API, such as the file connection package, to access the file system. An applica-
tion gains trust by virtue of the domain from which it came; typically the application
carries this information through a cryptographic signature applied by a certification
authority or carrier. As a result, even when bearing privilege, applications must be pre-
pared for security exceptions, which may occur when an application is untrusted and
attempts to access a restricted API.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 13
42.
Introducing the FoundationProfile
The Foundation Profile, targeted for CDC-enabled devices, runs on devices with less than
256KB of ROM (of course, a Foundation Profile device can have more ROM, but that’s the
minimum supported by the profile), a minimum of 512KB of RAM, and a persistent net-
work connection. In many ways, the Foundation Profile is far less ambitious than the
MIDP
. In conjunction with the CDC, it provides network and input/output (I/O) support,
but no classes for application development; those are relegated instead to the Personal
Basis Profile and the Personal Profile.
Classes augmented by the Foundation Profile include those in the java.lang, java.io,
java.net, java.security, java.text, and java.util packages.These classes are based on classes
found in the Java SE 1.4 class hierarchy, as well as additional javax.microedition.io classes
that provide HTTP and HTTP-over-Transport Layer Security (TLS) network operations.
Introducing the Personal Basis Profile
Most CDC-based devices have at least some user-interface requirements. The most highly
embedded devices may use only the Foundation Profile with a custom package atop that
to provide support for a custom-made liquid-crystal or light-emitting diode (LED) display,
but by far the most common are devices with raster displays that need rich graphical user
interfaces (GUIs). To accommodate this in a standard way, two profiles are available. The
smaller of the two, the Personal Basis Profile, actually provides two class hierarchies for
applications: the applet model, and a new hierarchy for media devices that defines the
Xlet programming model. Xlets are similar to applets, except they have a life cycle that
supports being paused and resumed, which is important for media devices in which mul-
tiple applications and media streams may interrupt an application’s execution at any time.
The Personal Basis Profile also defines a subset of the AWT for GUI development.
Unlike the traditional AWT, the Personal Basis Profile defines a lightweight control facil-
ity, in which user-interface components draw themselves rather than have peer controls
derived from the native platform. (The Java Swing implementation takes the same
approach of having the Java environment draw its own controls.) Consequently, the
Personal Basis Profile only includes support for java.awt.Window and java.awt.Frame
(which hook to the native platform’s windowing manager and contain lightweight
components), and java.awt.Component and java.awt.Container (which are lightweight
components used to create all of the other components in the hierarchy). Note that the
Personal Basis profile does not define traditional AWT controls, including buttons, lists,
and other items, because these would have connections to peer components from the
native platform. Instead, you can create your own components or import a package on a
specific platform that provides the components you need.
Finally, the Personal Basis Profile also includes classes that support communication
between Xlets, using a subset of Java’s Remote Method Invocation (RMI) API. It’s important
to remember, though, that while parts of the java.rmi package are included in the Personal
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
14
43.
Basis Profile, theprofile does not support RMI; just enough of the RMI implementation is
included to facilitate communication between two Xlets running on the same device.
Introducing the Personal Profile
The Personal Profile is a superset of the Personal Basis Profile that provides support
for the entire AWT, as well as limited JavaBean support. Some readers may remember
PersonalJava, the predecessor to Java ME that was targeted for higher-end Internet
appliances and set-top boxes; the Personal Profile atop the CDC is the forward migra-
tion path for applications running on PersonalJava.
In fact, the Personal Profile is almost the same as Java SE 1.4.2, with these differences:
• Support for RMI is available through an optional package (java.rmi).
• Support for SQL is available through an optional package (java.sql).
• Support for Java Swing is available through an optional package (java.swing).
• Support for Object Management Group (OMG) interfaces, including Common
Object Request Broker Architecture (CORBA), is available through an optional
package (org.omg).
• There is no support at present for the Java Accessibility API (javax.accessibility).
• There is no support at present for the Java Naming and Directory Interface (JNDI)
in java.naming.
• There is no support for the Java Sound API (java.sound).
• Support for JavaBeans is limited to runtime support; there is no support for bean
editors running directly on a CDC environment.
• The applet API getAccessibleContext is not supported.
• Applet and AWT methods deprecated from Java SE have been removed from all
supported classes.
Understanding Packages
A package, as its name implies, is an object or group of objects in a common container.
As important as platforms and profiles are to the modularity of the Java ME platform,
packages are arguably the key to Java ME’s continued success, as they permit Sun and
third-party vendors to extend the Java ME platform for specific families of devices.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 15
44.
There are countlesspackages for Java ME; many of the now-standard interfaces that
are part of successful MIDP-based devices are in fact packages. In this book, you will
learn how to use several packages, including
• The GCF, documented in JSR 30
• The FileConnect interface, which provides local file access on MIDP and is
documented in JSR 75
• The Java Bluetooth API, documented in JSR 82
• The Wireless Messaging API, documented in JSR 120
• The Web Services API, documented in JSR 172
• The Java Advanced Graphics and User Interface (AGUI) API, for CDC devices,
documented in JSR 209
• The Java Mobile Service Architecture (MSA), documented in JSR 248
Planning Your Approach to Java ME Development
Java ME’s strength is rooted in the ubiquity of Java today. However, with this ubiquity
comes challenges. The multitude of APIs and the diversity of distribution channels make
planning the technical and business aspects of your application equally important.
Selecting Appropriate Device Targets
As you’ve seen, the triad of configurations, profiles, and packages means managing a
lot of different APIs. For many kinds of applications, this may not be a serious problem—
most productivity and network applications need just a network layer, some GUI
elements, and a persistent store, which is available under just about any combination
of configuration and profile you might encounter.
That’s not always the case, however. Your application might depend on functional-
ity present in only a specific package, perhaps, either by design (say, a Bluetooth-
derived application for proximity detection) or product differentiation. There’s always
the temptation of using an optional package to speed time to market, too, only to find
later that it’s not available on the next target for your product.
Consequently, if portability is important, you should base your application on as
few Java ME packages as you possibly can. Obviously, this doesn’t mean creating your
own control framework from scratch or implementing your own web services frame-
work from scratch if you don’t have to. But it does mean understanding what APIs are
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
16
45.
available on thedevices you’re targeting, and performing regular surveys of the market.
I find it best to keep track of what APIs I plan to use as I design and implement my
application, and correlate them against the JSRs that define those APIs. Then, when it’s
time to bring my application to market on a different device, I can check to see which
packages are offered by the new hardware and scope my porting effort accordingly.
Sites like the Wireless Universal Resource File (WURFL) device description repository
at http://wurfl.sourceforge.net and the support database for J2ME Polish (a library
originally targeted at Java ME’s predecessor, J2ME, that simplifies cross-device devel-
opment) at http://devices.j2mepolish.org/ are invaluable in planning your product
launch or porting efforts. A little research as you design your application can pay big
dividends when rolling it out to consumers.
Marketing and SellingYour Application
There are a myriad of channels for Java ME applications today, each with their own set
of business challenges. Many readers see wireless operators as the logical channel for
application distribution, given the popularity of the MIDP today. Still others target web
distribution to hardware directly or bundle applications with hardware at manufactur-
ing time. A small percentage of you may be working directly with platform or hardware
manufacturers, and so your channel to the consumer (and the notion of a consumer
itself!) is quite different.
You can distribute your application to consumers in a number of ways. Certainly
direct distribution is a possibility, by publishing a link to your application (see Chapter 3
for how to package your application for the different configurations). This may sound
simple, but it poses an obvious business question: How will you get paid for your applica-
tion? Free distribution, advertising, and per-download or subscriptions via credit card or
PayPal fulfillment are all possibilities.
Because of the need for privilege by most applications and revenue by most
developers, a typical deployment for a mobile application involves both third-party
certification and business negotiations. The process of third-party certification typi-
cally involves a business program such as Java Verified, which tests your application,
and assuming it passes testing, cryptographically signs your application for distribu-
tion. Usually accompanying this signed endorsement is access to additional privileges;
for example, most MIDP implementations won’t permit HTTP transactions without
prior user approval unless a member of the Java Verified testing authority has signed
the application. Once signed, you can distribute your application through aggregators,
who broker the carrier relationship on behalf of you and many other developers, reim-
bursing you for sales (typically via a premium-SMS push or direct billing). Another
distribution path is to negotiate with one or more wireless operators to distribute your
application. This involves crafting the business relationship—how much will con-
sumers pay for your application, and how will it be obtained?—as well as additional
testing, which usually results in a second cryptographic signature for your application.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE 17
46.
With this signaturemay come additional privileges, such as access to location-based
APIs. Negotiating operator partnerships can be an expensive and time-consuming task,
but without the help of an intermediate aggregator, you need to perform these negotia-
tions for each operator’s network on which you want to deliver your application.
This issue of privileges and cryptographic signatures isn’t just a business issue, but
can be a functional issue as well. This may very well affect the functional requirements
for your application; for example, Acme Wireless (a fictitious operator) might only permit
applications access to location-based interfaces for applications it signs and distributes.
If your application needs positioning data (say, to locate the user to recommend restau-
rants or services), that requirement won’t be just a technical requirement but a business
requirement to establish the necessary operator relationship to ensure the required privi-
lege. This admittedly adds risk to your business model, because it’s difficult to ascertain
in advance whether or not specific operators will carry your application, and obtaining
this information in advance can involve significant business investment. It does, how-
ever, give you certain assurances if you can bridge the gap and obtain operator signing
and distribution for your application, because this gives significant placement and mar-
keting clout for your application. While all of these comments apply primarily to Java ME
MIDP applications, due to the large number of MIDP applications and MIDP-capable
devices on the market, I suspect that the landscape for Java CDC applications will be sim-
ilar, given the rampant success of the MIDP distribution model.
Of course, if you’re a developer involved in planning your business strategy, don’t for-
get other avenues for distribution, too. Direct-to-manufacturer deals, while difficult to
obtain, are potentially lucrative sources of long-term revenue. Moreover, providing serv-
ices for Java consulting remains an important mainstay for many developers. Thinking
creatively, a host of business models can support your application’s development and
distribution.
Wrapping Up
Java ME meets needs for operators, device manufacturers, and consumers. By providing
a rich set of platforms across devices from low-end mobile phones to high-end set-top
boxes, and from embedded devices to high-end PDAs, Java ME enables software develop-
ers like you to leverage your skills to bring new applications to market.
The Java ME platform is divided up into configurations, platforms, and profiles. Two
configurations are presently available: the CLDC, which is targeted for constrained
devices, and the CDC, which is targeted for more robust devices. Atop these configura-
tions are one or more profiles, such as MIDP for the CLDC, or the Foundation, Personal
Basis, and Personal Profiles for the CDC. These provide additional APIs in a standard way
that let you write your application for a family of devices. Finally, packages allow Sun and
third parties to extend the APIs on a device or suite of devices in a standard way, giving
access to new functionality in portable ways.
CHAPTER 1 ■ MAPPING THE JAVA JUNGLE
18
47.
Shrinking Java toFit
Making Java run on constrained devices remains a challenge, even nearly a decade
after the first attempts to do so. However, the configurations provided by Java ME are
helping to meet this challenge by bringing the Java platform to the widest possible selec-
tion of devices. By splitting Java into separate configurations—the CLDC for devices with
the lowest possible throughput, and the CDC for constrained mobile devices with mod-
erate memory and processing power—Java ME can provide a computing environment
for nearly every mobile device.
In this chapter, I show you the explicit differences between Java ME and Java SE.
I begin with the CLDC, showing you just what’s different between past and present
versions of the CLDC’s virtual machine and the virtual machine running the Java SE.
Next I look at the CDC the same way. Finally, I turn your attention to the class libraries
accompanying each of these configurations, showing you precisely which classes both
the CLDC and the CDC support.
Making It Fit: The CLDC
To understand the limitations of the Java ME CLDC, it’s important to understand a bit
about the history of the CLDC itself. The CLDC stems from early in the history of Java
when mobile devices were veritable cripples by today’s standards. Mobile phones had
well under a megabyte of heap and were powered by processors that would be consid-
ered anemic by today’s standards. The initial release of the CLDC was based on an
entirely new virtual machine for small devices, the Java KVM. Consequently, it lacked a
lot of what Java developers were used to. CLDC 1.0, which was documented in JSR 30 in
2000, was the starting point for what has become the Java ME platform.
To keep pace with developments in hardware capabilities and manufacturing costs,
an expert working group of more than 20 companies revised the CLDC standard, result-
ing in JSR 139, which is the standard that defines CLDC 1.1. This standard, completed in
2002, took into account the growing capabilities and markets for mobile devices, and it
added back some features stripped from Java to make Java fit on mobile devices during
the brief period that CLDC 1.0 was available.
19
C H A P T E R 2
48.
The distinction betweenthe CLDC 1.0 and 1.1 releases may or may not affect your
development approach, as the overwhelming majority of new devices sold today support
CLDC 1.1 (or the CDC, in fact, for some higher-end devices). For example, as I write this,
virtually all wireless operators’ Java-enabled feature phones—those phones subsidized by
operators to provide a mix of features at a low cost to drive both voice and data uses—are
CLDC 1.1–compliant. Even accounting for device churn (the rate at which users buy new
devices), there are countless CLDC 1.0 devices on the market, and a savvy developer may
well be able to wring revenue from these users. On the other hand, many of the com-
pelling features of the Java ME platform (available through packages documented by the
JSR process, as I discuss in Chapter 1), such as multimedia and 3D graphics, are only
available on relatively new handsets, which typically run CLDC 1.1 and MIDP 2.0 or 2.1.
As a result, when you plan your application, you should balance the need for APIs pro-
vided by a later version of the CLDC or MIDP with the business case provided. You’ll need
to answer this question: do the technology requirements for your application so drasti-
cally reduce the number of devices on which you can deliver your application that your
business case becomes invalid? This is a common theme for cutting-edge Java ME devel-
opers, but less so now than in years past, and over time (as I discuss in the section
“Looking Toward the Future of the CLDC” in this chapter) it should diminish entirely.
Understanding the Present: CLDC 1.1
Cost and power consumption significantly limit the capabilities of even today’s mobile
devices. While consumer demand for high-capability personalizable devices remains
high, manufacturing cost remains a key factor and drives the selection of low-cost com-
ponents (meaning less memory, slower processors, and so forth). While Moore’s law has
driven ever-faster and ever-cheaper devices in the hands of consumers, power sources
have been unable to keep up, making power management another key challenge for
mobile devices. Consequently, there continues to be constrained devices and a role for
the CLDC on those devices.
Specifically, CLDC 1.1 differs from Java SE in the following ways:
• CLDC 1.1 offers no finalization of object instances: CLDC libraries, by definition,
do not include the method Object.finalize.
• CLDC 1.1 doesn’t support asynchronous exceptions: The virtual machine does not
throw asynchronous exceptions, and you cannot invoke Thread.stop, as it doesn’t
exist in the CLDC.
• CLDC 1.1 supports only a limited number of the java.lang.Error subclasses:
For other errors, the CLDC either halts the virtual machine in an implementation-
specific manner or throws the nearest defined java.lang.Error subclass. (See the
“Changes to java.lang.Exception” section later in this chapter.)
CHAPTER 2 ■ SHRINKING JAVA TO FIT
20
49.
• CLDC 1.1doesn’t support thread groups or daemon threads: The CLDC does sup-
port multithreading, but if you need to manage a group of threads, you must use
individual thread operations on members of a collection.
• Class file verification is a two-step process in CLDC 1.1: As I discuss in the “Building
CLDC/MIDP Applications” section in Chapter 3, the CLDC requires a preverifica-
tion step during application development and a subsequent completion of
verification after downloading.
• For security reasons, CLDC 1.1 doesn’t support user-defined class loaders: The CLDC
must have an internal class loader that other code cannot override, replace, or
reconfigure in any way.
With the possible exception of CLDC 1.1 lacking class finalization and thread groups,
these differences are unlikely to affect your approach to application development. Larger
in scope, however, is the reduction of the CLDC class library itself, which I explore later in
the chapter (in the section “Changing the Java Class Library to Fit the CLDC”).
MOORE’S LAW AND MOBILE DEVICES
Moore’s law—the observation that the number of transistors that can be fit on the die of an integrated
circuit is increasing exponentially—has driven many facets of the computing revolution, including the
increases in computing speed and memory density for more than 50 years. Documented by Gordon
Moore in an article in Electronics Magazine in 1965, the law isn’t one of nature, but rather a recognition
of the economies of scale provided by integrated circuit production.
For mobile devices, Moore’s law brings two key points: the ever-dropping cost of each transistor
means that more computing power can be purchased for less money, and that the increased transistor
density brings faster devices with more memory in portable form factors at the same exponential pace
as it brings to desktop users. That is not to say, however, that the capabilities of mobile and desktop
devices will converge, as Moore’s law is in play for larger computing platforms as well.
Moreover, one area remaining largely untouched by Moore’s law is in providing energy for mobile
devices. While the battery industry has seen many improvements in technology over the last two
decades, these advancements have not been exponential in nature, leading to aggressive work on the
part of hardware and software developers to manage power consumption at the hardware and soft-
ware levels. This has a direct impact on computational resources, of course, which consume power
while operating.
These factors are likely to persist into the future, meaning that while mobile devices continue to
get increasingly powerful, it’s unlikely that mobile devices and desktops will ever truly converge.
Instead, it’s likely that mobile devices will become sufficient to support the majority of operations per-
formed by yesterday’s desktops—something I talk more about in the “Looking Toward the Future of the
CLDC” section later in this chapter.
CHAPTER 2 ■ SHRINKING JAVA TO FIT 21
50.
Looking Back atCLDC 1.0
CLDC 1.0 had significantly more limitations than CLDC 1.1, as you can imagine when
you consider the time in which it was developed. When developing a CLDC 1.0–
compliant application, you must consider the following limitations:
• No floating-point operations: CLDC 1.0–compliant virtual machines have no
support for floating-point byte codes, nor do they have library APIs that perform
floating-point math. These limitations mirror the capabilities of the processors
typically targeted by CLDC 1.0.
• No support for weak references: The WeakReference declaration is not supported by
CLDC 1.0–compliant virtual machines.
• No support for named threads: The CLDC-compliant virtual machines have no
support for naming threads.
• Different uses of java.util.Calendar, java.util.Date, and java.util.TimeZone classes:
These classes differ significantly from their Java SE counterparts.
Looking Toward the Future of the CLDC
Although I believe that true convergence of capability between mobile devices and
fixed devices remains a long way off (see the “Moore’s Law and Mobile Devices” side-
bar), mobile devices are arguably reaching parity with desktop devices in terms of basic
usability for many applications, including data processing, multimedia, entertainment,
social networking, and user-generated content. Already, some high-end wireless termi-
nals, such as those sold by Nokia and Sony Ericsson, offer CDC-compliant runtimes
as well as CLDC-compliant runtimes. Looking into the future, representatives of Sun
have already stated that eventually the Java ME and Java SE interfaces will merge into
a single platform.
Does this make the CLDC less relevant? Certainly not, as literally billions of
devices running the CLDC are already in consumers’ hands, and billions more are to
be shipped in the coming years. Instead, expect to see a filling in of the gaps between
the CLDC and the full Java SE platform, much as the transition from CLDC 1.0 to
CLDC 1.1 filled in gaps.
CHAPTER 2 ■ SHRINKING JAVA TO FIT
22
51.
Making It Fit:The CDC
In some ways, the CDC has had a more tumultuous history than its smaller cousin, the CLDC.
Beginning life as PersonalJava and based on Java 1.1.8, the CDC is actually quite old, dating
back to the late nineties. PersonalJava consisted of a heavily optimized JavaVM and an associ-
ated class library that incorporated most of the Java stack, including a GUI, for application
developers on set-top boxes, high-end connected wireless terminals, and other products.
A few years ago, Sun announced the trio of flavors for Java: Java 2 Platform, Micro
Edition (J2ME), Java 2 Platform, Standard Edition (J2SE), and Java 2 Platform, Enterprise
Edition (J2EE). While PersonalJava remained, it was subsumed into Java ME and later
reached its end of life, meaning that Sun withdrew support for the platform.
At the same time, Sun introduced JSR 36, defining the CDC. The CDC targets devices
requiring an entire virtual machine for hardware that, through optional extensions, may
run the entire Java 2 platform. JSR 36 bases its implementation on Java SE 1.3, and it
includes all additional interfaces defined by the CLDC, providing a migration path for-
ward from CLDC devices. JSR 218, defining CLDC 1.1.2, normalized the interfaces
provided against Java SE 1.4.2, helping ensure parity going forward between the CDC
and larger Java environments.
It does little good to identify each and every class in the CDC, because the list is the
same as the list of classes for Java SE. It is, however, worth your while for me to call out
the packages included in the CDC, because while the CDC provides a baseline for com-
patibility, it does not provide the user-interface classes necessary to build a full
application. Table 2-1 shows the packages provided by the CDC.
Table 2-1. Packages Provided by CDC 1.1.2
java.io
java.lang
java.lang.ref
java.lang.reflect
java.math
java.net
java.security
java.security.cert
java.text
java.util
java.util.jar
java.util.zip
javax.microedition.io
CHAPTER 2 ■ SHRINKING JAVA TO FIT 23
52.
The CDC isa more restrictive environment than Java SE. Be aware of the following:
• If the CDC implementation with which you’re working supports invoking native
methods, you must use Java Native Interface (JNI) 1.1 to interface with those native
methods.
• If the CDC implementation with which you’re working supports a debugging
interface, you must use the Java Virtual Machine Debug Interface (JVMDI) for
debugging.
• The CDC doesn’t support secure code signing, certificates, the key store, and the
JDK 1.1 java.security.Identity and java.security.IdentityScope interfaces.
Typically, any CDC implementation you encounter is accompanied by one or
more profiles, such as the Foundation Profile, giving you support for GUIs and other
capabilities.
Changing the Java Class Library to Fit the CLDC
Shrinking the Java virtual machine was only part of the trick to making the CLDC fit
on mobile devices. One of Java’s key benefits to developers is its robust class library.
However, all of that code is also in Java and consumes precious read-only memory
space on constrained devices, and some classes may not even be appropriate because
of their runtime memory consumption. Of course, without its class hierarchy, Java
wouldn’t be nearly as compelling a platform, so the architects of the CLDC struck a
balance, establishing an environment with relatively few Java interfaces that can run
on the widest possible variety of devices while supporting a great number of applica-
tions. (And of course, device manufacturers are free to add—and have added—a great
number of additional interfaces.)
Besides the obvious—as you know, neither the AWT nor Java Swing are part of the
CLDC—many other classes, and some methods of other classes, are omitted from the
CLDC. In the following sections, I show you which parts of the java.lang, java.util, and
java.io hierarchies are different between CLDC 1.0, CLDC 1.1, and Java SE, as well as the
additions made by the CLDC to the Java family of libraries.
Changes to the java.lang Package
Table 2-2 lists the classes inherited from the java.lang package. Many of these classes are
a subset of the implementation found in Java SE.
CHAPTER 2 ■ SHRINKING JAVA TO FIT
24
53.
Table 2-2. java.langClasses Supported by CLDC Version
CLDC 1.0 CLDC 1.1
ArithmeticException ArithmeticException
ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException
ArrayStoreException ArrayStoreException
Boolean Boolean
Byte Byte
Character Character
Class Class
ClassCastException ClassCastException
ClassNotFoundException ClassNotFoundException
Error Error
Exception Exception
IllegalAccessException IllegalAccessException
IllegalArgumentException IllegalArgumentException
IllegalMonitorStateException IllegalMonitorStateException
IllegalThreadStateException IllegalThreadStateException
IndexOutOfBoundsException IndexOutOfBoundsException
InstantiationException InstantiationException
InterruptedException InterruptedException
Integer Integer
Long Long
Math Math
NegativeArraySizeException NegativeArraySizeException
NumberFormatException NumberFormatException
NullPointerException NullPointerException
Object Object
OutOfMemoryError OutOfMemoryError
Runnable Runnable (interface)
Runtime Runtime
RuntimeException RuntimeException
SecurityException SecurityException
Short Short
Continued
CHAPTER 2 ■ SHRINKING JAVA TO FIT 25
54.
Table 2-2. Continued
CLDC1.0 CLDC 1.1
String String
StringBuffer StringBuffer
StringIndexOutOfBoundsException StringIndexOutOfBoundsException
System System
Thread Thread
Throwable Throwable
VirtualMachineError VirtualMachineError
Double
Float
NoClassDefFoundError
Reference
WeakReference
Changes to java.lang.Exception
As I stated previously, the exception hierarchy for the java.lang package is significantly
smaller than the hierarchy for Java SE.
Changes to java.lang.Object
The key change to the Object class—and therefore the entire Java hierarchy—is the
absence of the finalize method. As you know, the memory manager invokes a method’s
finalize method just before garbage collection; in the CLDC, there’s no way to hook the
garbage-collection process in this manner. This is as it should be: memory is often a pre-
cious commodity on Java ME devices anyway, so you should explicitly clean up resources
when you’re finished using them.
The Reflection API is also not part of the CLDC; the memory footprint it demands
just isn’t feasible. Of course, without reflection, there’s no RMI, and without RMI, there’s
no Jini—Sun’s platform for Java-based distributed computing.
Changes to java.lang.Math
As you might imagine, with the removal of floating-point support in CLDC 1.0, the
java.math class was stripped of floating-point operations, leaving only operations with
all-integer signatures such as min and max. With the reintroduction of floating-point
CHAPTER 2 ■ SHRINKING JAVA TO FIT
26
for shame.' AndI say, 'So, so, my child! tell it not, then—tell it not at
all.' She shakes her head at me, and wrings her two hands together,
like this, on the bed-cover. 'I must tell it,' she says. 'I must rid my
heart of all that has been gnawing, gnawing, gnawing at it, or how
shall I feel the blessing that the seeing her will bring to me, if my
conscience is only clear?' Then she stops a little, and lifts up her two
hands, so, and cries out loud, 'Oh, will God's mercy show me no way
of telling it that will spare me before my child!' And I say, 'Hush,
then! there is a way. Tell it to Uncle Joseph, who is the same as
father to you! Tell it to Uncle Joseph, whose little son died in your
arms; whose tears your hand wiped away, in the grief time long ago.
Tell it, my child, to me; and I shall take the risk, and the shame (if
there is shame), of telling it again. I, with nothing to speak for me
but my white hair; I, with nothing to help me but my heart that
means no harm—I shall go to that good and true woman, with the
burden of her mother's grief to lay before her; and, in my soul of
souls I believe it, she will not turn away!'"
He paused, and looked at Rosamond. Her head was bent down
over her child; her tears were dropping slowly, one by one, on the
bosom of his little white dress. Waiting a moment to collect herself
before she spoke, she held out her hand to the old man, and firmly
and gratefully met the look he fixed on her. "Oh, go on, go on!" she
said. "Let me prove to you that your generous confidence in me is
not misplaced."
"I knew it was not, from the first, as surely as I know it now!" said
Uncle Joseph. "And Sarah, when I had spoken to her, she knew it
too. She was silent for a little; she cried for a little; she leaned over
from the pillow and kissed me here, on my cheek, as I sat by the
bedside; and then she looked back, back, back, in her mind, to the
Long Ago, and very quietly, very slowly, with her eyes looking into
my eyes, and her hand resting so in mine, she spoke the words to
me that I must now speak again to you, who sit here to-day as her
judge, before you go to her to-morrow as her child."
"Not as her judge!" said Rosamond. "I can not, I must not hear
you say that."
57.
"I speak herwords, not mine," rejoined the old man, gravely.
"Wait before you bid me change them for others—wait till you know
the end."
He drew his chair a little nearer to Rosamond, paused for a minute
or two to arrange his recollections, and to separate them one from
the other; then resumed.
"As Sarah began with me," he said, "so I, for my part, must begin
also—which means to say, that I go down now through the years
that are past, to the time when my niece went out to her first
service. You know that the sea-captain, the brave and good man
Treverton, took for his wife an artist on the stage—what they call
play-actress here? A grand, big woman, and a handsome; with a life
and a spirit and a will in her that is not often seen; a woman of the
sort who can say, We will do this thing, or that thing—and do it in
the spite and face of all the scruples, all the obstacles, all the
oppositions in the world. To this lady there comes for maid to wait
upon her, Sarah, my niece—a young girl then, pretty and kind and
gentle, and very, very shy. Out of many others who want the place,
and who are bolder and bigger and quicker girls, Mistress Treverton,
nevertheless, picks Sarah. This is strange, but it is stranger yet that
Sarah, on her part, when she comes out of her first fears and
doubts, and pains of shyness about herself, gets to be fond with all
her heart of that grand and handsome mistress, who has a life and a
spirit and a will of the sort that is not often seen. This is strange to
say, but it is also, as I know from Sarah's own lips, every word of it
true."
"True beyond a doubt," said Leonard. "Most strong attachments
are formed between people who are unlike each other."
"So the life they led in that ancient house of Porthgenna began
happily for them all," continued the old man. "The love that the
mistress had for her husband was so full in her heart that it
overflowed in kindness to every body who was about her, and to
Sarah, her maid, before all the rest. She would have nobody but
Sarah to read to her, to work for her, to dress her in the morning and
the evening, and to undress her at night. She was as familiar as a
58.
sister might havebeen with Sarah, when they two were alone, in the
long days of rain. It was the game of her idle time—the laugh that
she liked most—to astonish the poor country maid, who had never
so much as seen what a theatre's inside was like, by dressing in fine
clothes, and painting her face, and speaking and doing all that she
had done on the theatre-scene in the days that were before her
marriage. The more she puzzled Sarah with these jokes and pranks
of masquerade, the better she was always pleased. For a year this
easy, happy life went on in the ancient house—happy for all the
servants—happier still for the master and mistress, but for the want
of one thing to make the whole complete, one little blessing that
was always hoped for, and that never came—the same, if you
please, as the blessing in the long white frock, with the plump,
delicate face and the tiny arms, that I see before me now."
He paused, to point the allusion by nodding and smiling at the
child in Rosamond's lap; then resumed.
"As the new year gets on," he said, "Sarah sees in the mistress a
change. The good sea-captain is a man who loves children, and is
fond of getting to the house all the little boys and girls of his friends
round about. He plays with them, he kisses them, he makes them
presents—he is the best friend the little boys and girls have ever
had. The mistress, who should be their best friend too, looks on and
says nothing—looks on, red sometimes, and sometimes pale; goes
away into her room where Sarah is at work for her, and walks about
and finds fault; and one day lets the evil temper fly out of her at her
tongue, and says, 'Why have I got no child for my husband to be
fond of? Why must he kiss and play always with the children of
other women? They take his love away for something that is not
mine. I hate those children and their mothers too!' It is her passion
that speaks then, but it speaks what is near the truth for all that.
She will not make friends with any of those mothers; the ladies she
is familiar-fond with are the ladies who have no children, or the
ladies whose families are all upgrown. You think that was wrong of
the mistress?"
59.
He put thequestion to Rosamond, who was toying thoughtfully
with one of the baby's hands which was resting in hers. "I think Mrs.
Treverton was very much to be pitied," she answered, gently lifting
the child's hand to her lips.
"Then I, for my part, think so too," said Uncle Joseph. "To be
pitied?—yes! To be more pitied some months after, when there is still
no child and no hope of a child, and the good sea-captain says, one
day, 'I rust here, I get old with much idleness; I want to be on the
sea again. I shall ask for a ship.' And he asks for a ship, and they
give it him; and he goes away on his cruises—with much kissing and
fondness at parting from his wife—but still he goes away. And when
he is gone, the mistress comes in again where Sarah is at work for
her on a fine new gown, and snatches it away, and casts it down on
the floor, and throws after it all the fine jewels she has got on her
table, and stamps and cries with the misery and the passion that is
in her. 'I would give all those fine things, and go in rags for the rest
of my life, to have a child!' she says. 'I am losing my husband's love:
he would never have gone away from me if I had brought him a
child!' Then she looks in the glass, and says between her teeth, 'Yes!
yes! I am a fine woman, with a fine figure, and I would change
places with the ugliest, crookedest wretch in all creation, if I could
only have a child!' And then she tells Sarah that the Captain's
brother spoke the vilest of all vile words of her, when she was
married, because she was an artist on the stage; and she says, 'If I
have no child, who but he—the rascal-monster that I wish I could
kill!—who but he will come to possess all that the Captain has got?'
And then she cries again, and says, 'I am losing his love—ah, I know
it, I know it!—I am losing his love!' Nothing that Sarah can say will
alter her thoughts about that. And the months go on, and the sea-
captain comes back, and still there is always the same secret grief
growing and growing in the mistress's heart—growing and growing
till it is now the third year since the marriage, and there is no hope
yet of a child; and once more the sea-captain gets tired on the land,
and goes off again for his cruises—long cruises, this time; away,
away, away, at the other end of the world."
60.
Here Uncle Josephpaused once more, apparently hesitating a little
about how he should go on with the narrative. His mind seemed to
be soon relieved of its doubts, but his face saddened, and his tones
sank lower, when he addressed Rosamond again.
"I must, if you please, go away from the mistress now," he said,
"and get back to Sarah, my niece, and say one word also of a mining
man, with the Cornish name of Polwheal. This was a young man that
worked well and got good wage, and kept a good character. He lived
with his mother in the little village that is near the ancient house;
and, seeing Sarah from time to time, took much fancy to her, and
she to him. So the end came that the marriage-promise was
between them given and taken; as it happened, about the time
when the sea-captain was back after his first cruises, and just when
he was thinking of going away in a ship again. Against the marriage-
promise nor he nor the lady his wife had a word to object, for the
miner, Polwheal, had good wage and kept a good character. Only the
mistress said that the loss of Sarah would be sad to her—very sad;
and Sarah answered that there was yet no hurry to part. So the
weeks go on, and the sea-captain sails away again for his long
cruises; and about the same time also the mistress finds out that
Sarah frets, and looks not like herself, and that the miner, Polwheal,
he lurks here and lurks there, round about the house; and she says
to herself, 'So! so! Am I standing too much in the way of this
marriage? For Sarah's sake, that shall not be!' And she calls for them
both one evening, and talks to them kindly, and sends away to put
up the banns next morning the young man Polwheal. That night, it is
his turn to go down into the Porthgenna mine, and work after the
hours of the day. With his heart all light, down into that dark he
goes. When he rises to the world again, it is the dead body of him
that is drawn up—the dead body, with all the young life, by the fall
of a rock, crushed out in a moment. The news flies here; the news
flies there. With no break, with no warning, with no comfort near, it
comes on a sudden to Sarah, my niece. When to her sweet-heart
that evening she had said good-by, she was a young, pretty girl;
when, six little weeks after, she, from the sick-bed where the shock
61.
threw her, gotup, all her youth was gone, all her hair was gray, and
in her eyes the fright-look was fixed that has never left them since."
The simple words drew the picture of the miner's death, and of all
that followed it, with a startling distinctness—with a fearful reality.
Rosamond shuddered, and looked at her husband. "Oh, Lenny!" she
murmured, "the first news of your blindness was a sore trial to me—
but what was it to this!"
"Pity her!" said the old man. "Pity her for what she suffered then!
Pity her for what came after, that was worse! Yet five, six, seven
weeks pass, after the death of the mining man, and Sarah in the
body suffers less, but in the mind suffers more. The mistress, who is
kind and good to her as any sister could be, finds out, little by little,
something in her face which is not the pain-look, nor the fright-look,
nor the grief-look; something which the eyes can see, but which the
tongue can not put into words. She looks and thinks, looks and
thinks, till there steals into her mind a doubt which makes her
tremble at herself, which drives her straight forward into Sarah's
room, which sets her eyes searching through and through Sarah to
her inmost heart. 'There is something on your mind besides your
grief for the dead and gone,' she says, and catches Sarah by both
the arms before she can turn way, and looks her in the face, front to
front, with curious eyes that search and suspect steadily. 'The miner
man, Polwheal,' she says; 'my mind misgives me about the miner
man, Polwheal. Sarah! I have been more friend to you than mistress.
As your friend I ask you now—tell me all the truth?' The question
waits; but no word of answer! only Sarah struggles to get away, and
the mistress holds her tighter yet, and goes on and says, 'I know
that the marriage-promise passed between you and miner Polwheal;
I know that if ever there was truth in man, there was truth in him; I
know that he went out from this place to put the banns up, for you
and for him, in the church. Have secrets from all the world besides,
Sarah, but have none from me. Tell me, this minute—tell me the
truth! Of all the lost creatures in this big, wide world, are you—?'
Before she can say the words that are next to come, Sarah falls on
her knees, and cries out suddenly to be let go away to hide and die,
62.
and be heardof no more. That was all the answer she gave. It was
enough for the truth then; it is enough for the truth now."
He sighed bitterly, and ceased speaking for a little while. No voice
broke the reverent silence that followed his last words. The one
living sound that stirred in the stillness of the room was the light
breathing of the child as he lay asleep in his mother's arms.
"That was all the answer," repeated the old man, "and the
mistress who heard it says nothing for some time after, but still looks
straight forward into Sarah's face, and grows paler and paler the
longer she looks—paler and paler, till on a sudden she starts, and at
one flash the red flies back into her face. 'No,' she says, whispering
and looking at the door, 'once your friend, Sarah, always your friend.
Stay in this house, keep your own counsel, do as I bid you, and
leave the rest to me.' And with that she turns round quick on her
heel, and falls to walking up and down the room—faster, faster,
faster, till she is out of breath. Then she pulls the bell with an angry
jerk, and calls out loud at the door—'The horses! I want to ride;'
then turns upon Sarah—'My gown for riding in! Pluck up your heart,
poor creature! On my life and honor, I will save you. My gown, my
gown, then; I am mad for a gallop in the open air!' And she goes
out, in a fever of the blood, and gallops, gallops, till the horse reeks
again, and the groom-man who rides after her wonders if she is
mad. When she comes back, for all that ride in the air, she is not
tired. The whole evening after, she is now walking about the room,
and now striking loud tunes all mixed up together on the piano. At
the bed-time, she can not rest. Twice, three times in the night she
frightens Sarah by coming in to see how she does, and by saying
always those same words over again: 'Keep your own counsel, do as
I bid you, and leave the rest to me.' In the morning she lies late,
sleeps, gets up very pale and quiet, and says to Sarah, 'No word
more between us two of what happened yesterday—no word till the
time comes when you fear the eyes of every stranger who looks at
you. Then I shall speak again. Till that time let us be as we were
before I put the question yesterday, and before you told the truth!'"
63.
At this pointhe broke the thread of the narrative again, explaining
as he did so that his memory was growing confused about a
question of time, which he wished to state correctly in introducing
the series of events that were next to be described.
"Ah, well! well!" he said, shaking his head, after vainly
endeavoring to pursue the lost recollection. "For once, I must
acknowledge that I forget. Whether it was two months, or whether it
was three, after the mistress said those last words to Sarah, I know
not—but at the end of the one time or of the other she one morning
orders her carriage and goes away alone to Truro. In the evening
she comes back with two large flat baskets. On the cover of the one
there is a card, and written on it are the letters 'S. L.' On the cover
of the other there is a card, and written on it are the letters 'R. T.'
The baskets are taken into the mistress's room, and Sarah is called,
and the mistress says to her, 'Open the basket with S. L. on it; for
those are the letters of your name, and the things in it are yours.'
Inside there is first a box, which holds a grand bonnet of black lace;
then a fine dark shawl; then black silk of the best kind, enough to
make a gown; then linen and stuff for the under garments, all of the
finest sort. 'Make up those things to fit yourself,' says the mistress.
'You are so much littler than I, that to make the things up new is
less trouble than, from my fit to yours, to alter old gowns.' Sarah, to
all this, says in astonishment, 'Why?' And the mistress answers, 'I
will have no questions. Remember what I said—Keep your own
counsel, and leave the rest to me!' So she goes out; and the next
thing she does is to send for the doctor to see her. He asks what is
the matter; gets for answer that Mistress Treverton feels strangely,
and not like herself; also that she thinks the soft air of Cornwall
makes her weak. The days pass, and the doctor comes and goes,
and, say what he may, those two answers are always the only two
that he can get. All this time Sarah is at work; and when she has
done, the mistress says, 'Now for the other basket, with R. T. on it;
for those are the letters of my name, and the things in it are mine.'
Inside this, there is first a box which holds a common bonnet of
black straw; then a coarse dark shawl; then a gown of good
64.
common black stuff;then linen, and other things for the under
garments, that are only of the sort called second best. 'Make up all
that rubbish,' says the mistress, 'to fit me. No questions! You have
always done as I told you; do as I tell you now, or you are a lost
woman.' When the rubbish is made up, she tries it on, and looks in
the glass, and laughs in a way that is wild and desperate to hear. 'Do
I make a fine, buxom, comely servant-woman?' she says. 'Ha! but I
have acted that part times enough in my past days on the theatre-
scene.' And then she takes off the clothes again, and bids Sarah
pack them up at once in one trunk, and pack the things she has
made for herself in another. 'The doctor orders me to go away out of
this damp, soft Cornwall climate, to where the air is fresh and dry
and cheerful-keen,' she says, and laughs again, till the room rings
with it. At the same time Sarah begins to pack, and takes some
knickknack things off the table, and among them a brooch which has
on it a likeness of the sea-captain's face. The mistress sees her,
turns white in the cheeks, trembles all over, snatches the brooch
away, and locks it up in the cabinet in a great hurry, as if the look of
it frightened her. 'I shall leave that behind me,' she says, and turns
round on her heel, and goes quickly out of the room. You guess now
what the thing was that Mistress Treverton had it in her mind to do?"
He addressed the question to Rosamond first, and then repeated it
to Leonard. They both answered in the affirmative, and entreated
him to go on.
"You guess?" he said. "It is more than Sarah, at that time, could
do. What with the misery in her own mind, and the strange ways
and strange words of her mistress, the wits that were in her were all
confused. Nevertheless, what her mistress has said to her, that she
has always done; and together alone those two from the house of
Porthgenna drive away. Not a word says the mistress till they have
got to the journey's end for the first day, and are stopping at their
inn among strangers for the night. Then at last she speaks out. 'Put
you on, Sarah, the good linen and the good gown to-morrow,' she
says, 'but keep the common bonnet and the common shawl till we
get into the carriage again. I shall put on the coarse linen and the
65.
coarse gown, andkeep the good bonnet and shawl. We shall pass so
the people at the inn, on our way to the carriage, without very much
risk of surprising them by our change of gowns. When we are out on
the road again, we can change bonnets and shawls in the carriage—
and then, it is all done. You are the married lady, Mrs. Treverton,
and I am your maid who waits on you, Sarah Leeson.' At that, the
glimmering on Sarah's mind breaks in at last: she shakes with the
fright it gives her, and all she can say is, 'Oh, mistress! for the love
of Heaven, what is it you mean to do?' 'I mean,' the mistress
answers, 'to save you, my faithful servant, from disgrace and ruin; to
prevent every penny that the captain has got from going to that
rascal-monster, his brother, who slandered me; and, last and most, I
mean to keep my husband from going away to sea again, by making
him love me as he has never loved me yet. Must I say more, you
poor, afflicted, frightened creature—or is it enough so?' And all that
Sarah can answer, is to cry bitter tears, and to say faintly, 'No.' 'Do
you doubt,' says the mistress, and grips her by the arm, and looks
her close in the face with fierce eyes—'Do you doubt which is best,
to cast yourself into the world forsaken and disgraced and ruined, or
to save yourself from shame, and make a friend of me for the rest of
your life? You weak, wavering, baby woman, if you can not decide
for yourself, I shall for you. As I will, so it shall be! To-morrow, and
the day after that, we go on and on, up to the north, where my
good fool of a doctor says the air is cheerful-keen—up to the north,
where nobody knows me or has heard my name. I, the maid, shall
spread the report that you, the lady, are weak in your health. No
strangers shall you see, but the doctor and the nurse, when the time
to call them comes. Who they may be, I know not; but this I do
know, that the one and the other will serve our purpose without the
least suspicion of what it is; and that when we get back to Cornwall
again, the secret between us two will to no third person have been
trusted, and will remain a Dead Secret to the end of the world!' With
all the strength of the strong will that is in her, at the hush of night
and in a house of strangers, she speaks those words to the woman
of all women the most frightened, the most afflicted, the most
helpless, the most ashamed. What need to say the end? On that
66.
night Sarah firststooped her shoulders to the burden that has
weighed heavier and heavier on them with every year, for all her
after-life."
"How many days did they travel toward the north?" asked
Rosamond, eagerly. "Where did the journey end? In England or in
Scotland?"
"In England," answered Uncle Joseph. "But the name of the place
escapes my foreign tongue. It was a little town by the side of the
sea—the great sea that washes between my country and yours.
There they stopped, and there they waited till the time came to send
for the doctor and the nurse. And as Mistress Treverton had said it
should be, so, from the first to the last, it was. The doctor and the
nurse, and the people of the house were all strangers; and to this
day, if they still live, they believe that Sarah was the sea-captain's
wife, and that Mistress Treverton was the maid who waited on her.
Not till they were far back on their way home with the child did the
two change gowns again, and return each to her proper place. The
first friend at Porthgenna that the mistress sends for to show the
child to, when she gets back, is the doctor who lives there. 'Did you
think what was the matter with me, when you sent me away to
change the air?' she says, and laughs. And the doctor, he laughs too,
and says, 'Yes, surely! but I was too cunning to say what I thought
in those early days, because, at such times, there is always fear of a
mistake. And you found the fine dry air so good for you that you
stopped?' he says. 'Well, that was right! right for yourself and right
also for the child.' And the doctor laughs again and the mistress with
him, and Sarah, who stands by and hears them, feels as if her heart
would burst within her, with the horror, and the misery, and the
shame of that deceit. When the doctor's back is turned, she goes
down on her knees, and begs and prays with all her soul that the
mistress will repent, and send her away with her child, to be heard
of at Porthgenna no more. The mistress, with that tyrant-will of hers,
has but four words of answer to give—'It is too late!' Five weeks
after, the sea-captain comes back, and the 'Too late' is a truth that
no repentance can ever alter more. The mistress's cunning hand that
67.
has guided thedeceit from the first, guides it always to the last—
guides it so that the captain, for the love of her and of the child,
goes back to the sea no more—guides it till the time when she lays
her down on the bed to die, and leaves all the burden of the secret,
and all the guilt of the confession, to Sarah—to Sarah, who, under
the tyranny of that tyrant-will, has lived in the house, for five long
years, a stranger to her own child!"
"Five years!" murmured Rosamond, raising the baby gently in her
arms, till his face touched hers. "Oh me! five long years a stranger
to the blood of her blood, to the heart of her heart!"
"And all the years after!" said the old man. "The lonesome years
and years among strangers, with no sight of the child that was
growing up, with no heart to pour the story of her sorrow into the
ear of any living creature, not even into mine! 'Better,' I said to her,
when she could speak to me no more, and when her face was
turned away again on the pillow—'a thousand times better, my child,
if you had told the Secret!' 'Could I tell it,' she said, 'to the master
who trusted me? Could I tell it afterward to the child, whose birth
was a reproach to me? Could she listen to the story of her mother's
shame, told by her mother's lips? How will she listen to it now, Uncle
Joseph, when she hears it from you? Remember the life she has led,
and the high place she has held in the world. How can she forgive
me? How can she ever look at me in kindness again?'"
"You never left her," cried Rosamond, interposing before he could
say more—"surely, surely, you never left her with that thought in her
heart!"
Uncle Joseph's head drooped on his breast. "What words of mine
could change it?" he asked, sadly.
"Oh, Lenny, do you hear that? I must leave you, and leave the
baby. I must go to her, or those last words about me will break my
heart." The passionate tears burst from her eyes as she spoke; and
she rose hastily from her seat, with the child in her arms.
"Not to-night," said Uncle Joseph. "She said to me at parting, 'I
can bear no more to-night; give me till the morning to get as strong
68.
as I can.'"
"Oh,go back, then, yourself!" cried Rosamond. "Go, for God's
sake, without wasting another moment, and make her think of me
as she ought! Tell her how I listened to you, with my own child
sleeping on my bosom all the time—tell her—oh, no, no! words are
too cold for it!—Come here, come close, Uncle Joseph (I shall always
call you so now); come close to me and kiss my child—her
grandchild!—Kiss him on this cheek, because it has lain nearest to
my heart. And now, go back, kind and dear old man—go back to her
bedside, and say nothing but that I sent that kiss to her!"
CHAPTER IV.
THE CLOSE OF DAY.
The night, with its wakeful anxieties, wore away at last; and the
morning light dawned hopefully, for it brought with it the promise of
an end to Rosamond's suspense.
The first event of the day was the arrival of Mr. Nixon, who had
received a note on the previous evening, written by Leonard's desire,
to invite him to breakfast. Before the lawyer withdrew, he had
settled with Mr. and Mrs. Frankland all the preliminary arrangements
that were necessary to effect the restoration of the purchase-money
of Porthgenna Tower, and had dispatched a messenger with a letter
to Bayswater, announcing his intention of calling upon Andrew
Treverton that afternoon, on private business of importance relating
to the personal estate of his late brother.
Toward noon, Uncle Joseph arrived at the hotel to take Rosamond
with him to the house where her mother lay ill.
69.
He came in,talking, in the highest spirits, of the wonderful change
for the better that had been wrought in his niece by the affectionate
message which he had taken to her on the previous evening. He
declared that it had made her look happier, stronger, younger, all in a
moment; that it had given her the longest, quietest, sweetest night's
sleep she had enjoyed for years and years past; and, last, best
triumph of all, that its good influence had been acknowledged, not
an hour since, by the doctor himself.
Rosamond listened thankfully, but it was with a wandering
attention, with a mind ill at ease. When she had taken leave of her
husband, and when she and Uncle Joseph were out in the street
together, there was something in the prospect of the approaching
interview between her mother and herself which, in spite of her
efforts to resist the sensation, almost daunted her. If they could
have come together, and have recognized each other without time to
think what should be first said or done on either side, the meeting
would have been nothing more than the natural result of the
discovery of the Secret. But, as it was, the waiting, the doubting, the
mournful story of the past, which had filled up the emptiness of the
last day of suspense, all had their depressing effect on Rosamond's
impulsive disposition. Without a thought in her heart which was not
tender, compassionate, and true toward her mother, she now felt,
nevertheless, a vague sense of embarrassment, which increased to
positive uneasiness the nearer she and the old man drew to their
short journey's end. As they stopped at last at the house door, she
was shocked to find herself thinking beforehand of what first words
it would be best to say, of what first things it would be best to do, as
if she had been about to visit a total stranger, whose favorable
opinion she wished to secure, and whose readiness to receive her
cordially was a matter of doubt.
The first person whom they saw after the door was opened was
the doctor. He advanced toward them from a little empty room at
the end of the hall, and asked permission to speak with Mrs.
Frankland for a few minutes. Leaving Rosamond to her interview
with the doctor, Uncle Joseph gayly ascended the stairs to tell his
70.
niece of herarrival, with an activity which might well have been
envied by many a man of half his years.
"Is she worse? Is there any danger in my seeing her?" asked
Rosamond, as the doctor led her into the empty room.
"Quite the contrary," he replied. "She is much better this morning;
and the improvement, I find, is mainly due to the composing and
cheering influence on her mind of a message which she received
from you last night. It is the discovery of this which makes me
anxious to speak to you now on the subject of one particular
symptom of her mental condition which surprised and alarmed me
when I first discovered it, and which has perplexed me very much
ever since. She is suffering—not to detain you, and to put the matter
at once in the plainest terms—under a mental hallucination of a very
extraordinary kind, which, so far as I have observed it, affects her,
generally, toward the close of the day, when the light gets obscure.
At such times, there is an expression in her eyes as if she fancied
some person had walked suddenly into the room. She looks and
talks at perfect vacancy, as you or I might look or talk at some one
who was really standing and listening to us. The old man, her uncle,
tells me that he first observed this when she came to see him (in
Cornwall, I think he said) a short time since. She was speaking to
him then on private affairs of her own, when she suddenly stopped,
just as the evening was closing in, startled him by a question on the
old superstitious subject of the re-appearance of the dead, and then,
looking away at a shadowed corner of the room, began to talk at it—
exactly as I have seen her look and heard her talk up stairs.
Whether she fancies that she is pursued by an apparition, or
whether she imagines that some living person enters her room at
certain times, is more than I can say; and the old man gives me no
help in guessing at the truth. Can you throw any light on the
matter?"
"I hear of it now for the first time," answered Rosamond, looking
at the doctor in amazement and alarm.
"Perhaps," he rejoined, "she may be more communicative with
you than she is with me. If you could manage to be by her bedside
71.
at dusk to-dayor to-morrow, and if you think you are not likely to be
frightened by it, I should very much wish you to see and hear her,
when she is under the influence of her delusion. I have tried in vain
to draw her attention away from it, at the time, or to get her to
speak of it afterward. You have evidently considerable influence over
her, and you might therefore succeed where I have failed. In her
state of health, I attach great importance to clearing her mind of
every thing that clouds and oppresses it, and especially of such a
serious hallucination as that which I have been describing. If you
could succeed in combating it, you would be doing her the greatest
service, and would be materially helping my efforts to improve her
health. Do you mind trying the experiment?"
Rosamond promised to devote herself unreservedly to this service,
or to any other which was for the patient's good. The doctor thanked
her, and led the way back into the hall again.—Uncle Joseph was
descending the stairs as they came out of the room. "She is ready
and longing to see you," he whispered in Rosamond's ear.
"I am sure I need not impress on you again the very serious
necessity of keeping her composed," said the doctor, taking his
leave. "It is, I assure you, no exaggeration to say that her life
depends on it."
Rosamond bowed to him in silence, and in silence followed the old
man up the stairs.
At the door of a back room on the second floor Uncle Joseph
stopped.
"She is there," he whispered eagerly. "I leave you to go in by
yourself, for it is best that you should be alone with her at first. I
shall walk about the streets in the fine warm sunshine, and think of
you both, and come back after a little. Go in; and the blessing and
the mercy of God go with you!" He lifted her hand to his lips, and
softly and quickly descended the stairs again.
Rosamond stood alone before the door. A momentary tremor
shook her from head to foot as she stretched out her hand to knock
at it. The same sweet voice that she had last heard in her bedroom
72.
at West Winstonanswered her now. As its tones fell on her ear, a
thought of her child stole quietly into her heart, and stilled its quick
throbbing. She opened the door at once and went in.
Neither the look of the room inside, nor the view from the
window; neither its characteristic ornaments, nor its prominent
pieces of furniture; none of the objects in it or about it, which would
have caught her quick observation at other times, struck it now.
From the moment when she opened the door, she saw nothing but
the pillows of the bed, the head resting on them, and the face
turned toward hers. As she stepped across the threshold, that face
changed; the eyelids drooped a little, and the pale cheeks were
tinged suddenly with burning red.
Was her mother ashamed to look at her?
The bare doubt freed Rosamond in an instant from all the self-
distrust, all the embarrassment, all the hesitation about choosing her
words and directing her actions which had fettered her generous
impulses up to this time. She ran to the bed, raised the worn,
shrinking figure in her arms, and laid the poor weary head gently on
her warm, young bosom. "I have come at last, mother, to take my
turn at nursing you," she said. Her heart swelled as those simple
words came from it—her eyes overflowed—she could say no more.
"Don't cry!" murmured the faint, sweet voice timidly. "I have no
right to bring you here and make you sorry. Don't, don't cry!"
"Oh, hush! hush! I shall do nothing but cry if you talk to me like
that!" said Rosamond. "Let us forget that we have ever been parted
—call me by my name—speak to me as I shall speak to my own
child, if God spares me to see him grow up. Say 'Rosamond,' and—
oh, pray, pray—tell me to do something for you!" She tore asunder
passionately the strings of her bonnet, and threw it from her on the
nearest chair. "Look! here is your glass of lemonade on the table.
Say 'Rosamond, bring me my lemonade!' say it familiarly, mother!
say it as if you knew that I was bound to obey you!"
She repeated the words after her daughter, but still not in steady
tones—repeated them with a sad, wondering smile, and with a
73.
lingering of thevoice on the name of Rosamond, as if it was a luxury
to her to utter it.
"You made me so happy with that message and with the kiss you
sent me from your child," she said, when Rosamond had given her
the lemonade, and was seated quietly by the bedside again. "It was
such a kind way of saying that you pardoned me! It gave me all the
courage I wanted to speak to you as I am speaking now. Perhaps
my illness has changed me—but I don't feel frightened and strange
with you, as I thought I should, at our first meeting after you knew
the Secret. I think I shall soon get well enough to see your child. Is
he like what you were at his age? If he is, he must be very, very—"
She stopped. "I may think of that," she added, after waiting a little,
"but I had better not talk of it, or I shall cry too; and I want to have
done with sorrow now."
While she spoke those words, while her eyes were fixed with
wistful eagerness on her daughter's face, the whole instinct of
neatness was still mechanically at work in her weak, wasted fingers.
Rosamond had tossed her gloves from her on the bed but the
minute before; and already her mother had taken them up, and was
smoothing them out carefully and folding them neatly together, all
the while she spoke.
"Call me 'mother' again," she said, as Rosamond took the gloves
from her and thanked her with a kiss for folding them up. "I have
never heard you call me 'mother' till now—never, never till now, from
the day when you were born!"
Rosamond checked the tears that were rising in her eyes again,
and repeated the word.
"It is all the happiness I want, to lie here and look at you, and
hear you say that! Is there any other woman in the world, my love,
who has a face so beautiful and so kind as yours?" She paused and
smiled faintly. "I can't look at those sweet rosy lips now," she said,
"without thinking how many kisses they owe me!"
"If you had only let me pay the debt before!" said Rosamond,
taking her mother's hand, as she was accustomed to take her child's,
74.
and placing iton her neck. "If you had only spoken the first time we
met, when you came to nurse me! How sorrowfully I have thought
of that since! Oh, mother, did I distress you much in my ignorance?
Did it make you cry when you thought of me after that?"
"Distress me! All my distress, Rosamond, has been of my own
making, not of yours. My kind, thoughtful love! you said, 'Don't be
hard on her'—do you remember? When I was being sent away,
deservedly sent away, dear, for frightening you, you said to your
husband, 'Don't be hard on her!' Only five words—but, oh, what a
comfort it was to me afterward to think that you had said them! I
did want to kiss you so, Rosamond, when I was brushing your hair. I
had such a hard fight of it to keep from crying out loud when I
heard you, behind the bed-curtains, wishing your little child good-
night. My heart was in my mouth, choking me all that time. I took
your part afterward, when I went back to my mistress—I wouldn't
hear her say a harsh word of you. I could have looked a hundred
mistresses in the face then, and contradicted them all. Oh, no, no,
no! you never distressed me. My worst grief at going away was
years and years before I came to nurse you at West Winston. It was
when I left my place at Porthgenna; when I stole into your nursery
on that dreadful morning, and when I saw you with both your little
arms round my master's neck. The doll you had taken to bed with
you was in one of your hands, and your head was resting on the
Captain's bosom, just as mine rests now—oh, so happily, Rosamond!
—on yours. I heard the last words he was speaking to you—words
you were too young to remember. 'Hush! Rosie, dear,' he said, 'don't
cry any more for poor mamma. Think of poor papa, and try to
comfort him!' There, my love—there was the bitterest distress and
the hardest to bear! I, your own mother, standing like a spy, and
hearing him say that to the child I dared not own! 'Think of poor
papa!' My own Rosamond! you know, now, what father I thought of
when he said those words! How could I tell him the Secret? how
could I give him the letter, with his wife dead that morning—with
nobody but you to comfort him—with the awful truth crushing down
75.
upon my heart,at every word he spoke, as heavily as ever the rock
crushed down upon the father you never saw!"
"Don't speak of it now!" said Rosamond. "Don't let us refer again
to the past: I know all I ought to know, all I wish to know of it. We
will talk of the future, mother, and of happier times to come. Let me
tell you about my husband. If any words can praise him as he ought
to be praised, and thank him as he ought to be thanked, I am sure
mine ought—I am sure yours will! Let me tell you what he said and
what he did when I read to him the letter that I found in the Myrtle
Room. Yes, yes, do let me!"
Warned by a remembrance of the doctor's last injunctions;
trembling in secret, as she felt under her hand the heavy, toilsome,
irregular heaving of her mother's heart, as she saw the rapid
changes of color, from pale to red, and from red to pale again, that
fluttered across her mother's face, she resolved to let no more words
pass between them which were of a nature to recall painfully the
sorrows and the suffering of the years that were gone. After
describing the interview between her husband and herself which
ended in the disclosure of the Secret, she led her mother, with
compassionate abruptness, to speak of the future, of the time when
she would be able to travel again, of the happiness of returning
together to Cornwall, of the little festival they might hold on arriving
at Uncle Joseph's house in Truro, and of the time after that, when
they might go on still farther to Porthgenna, or perhaps to some
other place where new scenes and new faces might help them to
forget all sad associations which it was best to think of no more.
Rosamond was still speaking on these topics, her mother was still
listening to her with growing interest in every word that she said,
when Uncle Joseph returned. He brought in with him a basket of
flowers and a basket of fruit, which he held up in triumph at the foot
of his niece's bed.
"I have been walking about, my child, in the fine bright sunshine,"
he said, "and waiting to give your face plenty of time to look happy,
so that I might see it again as I want to see it always, for the rest of
my life. Aha, Sarah! it is I who have brought the right doctor to cure
76.
you!" he addedgayly, looking at Rosamond. "She has made you
better already. Wait but a little while longer, and she shall get you up
from your bed again, with your two cheeks as red, and your heart as
light, and your tongue as fast to chatter as mine. See the fine
flowers and the fruit I have bought that is nice to your eyes, and
nice to your nose, and nicest of all to put into your mouth! It is
festival-time with us to-day, and we must make the room bright,
bright, bright, all over. And then, there is your dinner to come soon;
I have seen it on the dish—a cherub among chicken-fowls! And,
after that, there is your fine sound sleep, with Mozart to sing the
cradle song, and with me to sit for watch, and to go down stairs
when you wake up again, and fetch your cup of tea. Ah, my child,
my child, what a fine thing it is to have come at last to this festival-
day!"
With a bright look at Rosamond, and with both his hands full of
flowers, he turned away from his niece to begin decorating the
room. Except when she thanked the old man for the presents he had
brought, her attention had never wandered, all the while he had
been speaking, from her daughter's face; and her first words, when
he was silent again, were addressed to Rosamond alone.
"While I am happy with my child," she said, "I am keeping you
from yours. I, of all persons, ought to be the last to part you from
each other too long. Go back now, my love, to your husband and
your child; and leave me to my grateful thoughts and my dreams of
better times."
"If you please, answer Yes to that, for your mother's sake," said
Uncle Joseph, before Rosamond could reply. "The doctor says she
must take her repose in the day as well as her repose in the night.
And how shall I get her to close her eyes, so long as she has the
temptation to keep them open upon you?"
Rosamond felt the truth of those last words, and consented to go
back for a few hours to the hotel, on the understanding that she was
to resume her place at the bedside in the evening. After making this
arrangement, she waited long enough in the room to see the meal
brought up which Uncle Joseph had announced, and to aid the old
77.
Welcome to ourwebsite – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com