SlideShare a Scribd company logo
Mobile Java Development On Symbian Os Java Me
And Doja For Smartphones Roy Ben Hayun download
https://ebookbell.com/product/mobile-java-development-on-symbian-
os-java-me-and-doja-for-smartphones-roy-ben-hayun-1078948
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Learn Java For Android Development Migrating Java Se Programming
Skills To Mobile Development 4th Edition Peter Spth
https://ebookbell.com/product/learn-java-for-android-development-
migrating-java-se-programming-skills-to-mobile-development-4th-
edition-peter-spth-11231716
Java 16 Mobile Phones And Android Software Development No Isbn Poul
Klausen
https://ebookbell.com/product/java-16-mobile-phones-and-android-
software-development-no-isbn-poul-klausen-47502948
Android For Absolute Beginners Getting Started With Mobile Apps
Development Using The Android Java Sdk 1st Edition Grant Allen
https://ebookbell.com/product/android-for-absolute-beginners-getting-
started-with-mobile-apps-development-using-the-android-java-sdk-1st-
edition-grant-allen-31485194
The Definitive Guide To Modern Java Clients With Javafx Crossplatform
Mobile And Cloud Development 1st Edition Stephen Chin
https://ebookbell.com/product/the-definitive-guide-to-modern-java-
clients-with-javafx-crossplatform-mobile-and-cloud-development-1st-
edition-stephen-chin-10571836
Android For Absolute Beginners Getting Started With Mobile Apps
Development Using The Android Java Sdk Grant Allen
https://ebookbell.com/product/android-for-absolute-beginners-getting-
started-with-mobile-apps-development-using-the-android-java-sdk-grant-
allen-169380788
Comprehensive Java Programming Course Mastering Syntax Objectoriented
Concepts And Mobile Applications Development Taylor
https://ebookbell.com/product/comprehensive-java-programming-course-
mastering-syntax-objectoriented-concepts-and-mobile-applications-
development-taylor-56835408
Enterprise J2me Developing Mobile Java Applications 8th Print Yuan
https://ebookbell.com/product/enterprise-j2me-developing-mobile-java-
applications-8th-print-yuan-22042722
Enterprise J2me Developing Mobile Java Applications
https://ebookbell.com/product/enterprise-j2me-developing-mobile-java-
applications-1276916
Building Mobile Applications With Java Joshua Marinacci
https://ebookbell.com/product/building-mobile-applications-with-java-
joshua-marinacci-4098266
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Java ME on Symbian OS
Roy Ben Hayun
With
Sam Mason, Daniel Rocha, and Ivan Litovski, assisted by Sam
Cartwright
Reviewed by
Gavin Arrowsmith, Brendan Donegan, Erik Jacobson,
Martin de Jode, Mark Shackman, Jo Stichbury
Head of Symbian Press
Freddie Gjertsen
Managing Editor
Satu McNabb
A John Wiley and Sons, Ltd., Publication
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Java ME on Symbian OS
Inside the Smartphone Model
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Java ME on Symbian OS
Roy Ben Hayun
With
Sam Mason, Daniel Rocha, and Ivan Litovski, assisted by Sam
Cartwright
Reviewed by
Gavin Arrowsmith, Brendan Donegan, Erik Jacobson,
Martin de Jode, Mark Shackman, Jo Stichbury
Head of Symbian Press
Freddie Gjertsen
Managing Editor
Satu McNabb
A John Wiley and Sons, Ltd., Publication
Copyright  2009 John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester,
West Sussex PO19 8SQ, England
Telephone (+44) 1243 779777
Email (for orders and customer service enquiries): cs-books@wiley.com
Visit our Home Page on www.wiley.com
All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the
Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd,
Saffron House, 6–10 Kirby Street, London EC1N 8TS, UK, without the permission in writing of the Publisher. Requests to
the Publisher should be addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate,
Chichester, West Sussex PO19 8SQ, England, or emailed to permreq@wiley.com, or faxed to (+44) 1243 770620.
Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and
product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective
owners. The Publisher is not associated with any product or vendor mentioned in this book.
This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It
is sold on the understanding that the Publisher is not engaged in rendering professional services. If professional advice or
other expert assistance is required, the services of a competent professional should be sought.
Other Wiley Editorial Offices
John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA
Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA
Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany
John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia
John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809
John Wiley & Sons Canada Ltd, 6045 Freemont Blvd, Mississauga, Ontario, L5R 4J3, Canada
Wiley also publishes its books in a variety of electronic formats. Some content that appears
in print may not be available in electronic books.
Library of Congress Cataloging-in-Publication Data
Hayun, Roy Ben.
Java ME on Symbian OS : inside the smartphone model / Roy Ben Hayun, with Sam Mason ... [et al.].
p. cm.
Includes bibliographical references and index.
ISBN 978-0-470-74318-8 (pbk. : alk. paper) 1. Smartphones–Programming. 2. Java (Computer program language)
3. Symbian OS (Computer file) I. Title.
TK6570.M6H33 2009
005.26’8–dc22
2008053889
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
ISBN 978-0-47074318-8
Typeset in 10/12 Optima by Laserwords Private Limited, Chennai, India
Printed and bound in Great Britain by Bell & Bain, Glasgow
This book is printed on acid-free paper responsibly manufactured from sustainable forestry
in which at least two trees are planted for each one used for paper production.
Contents
Foreword ix
Kicking Butt with Java Technology on Symbian OS xv
About This Book xvii
Author Biographies xix
Author’s Acknowledgements xxi
Symbian Press Acknowledgements xxiii
Part One: Introduction to Java ME and
Programming Fundamentals 1
1 Introduction to Java ME, Symbian OS and
Smartphones 3
1.1 2003: Rise of the Mobile 3
1.2 2008: Mobile Generation 6
1.3 Meet the Host – Symbian OS 7
1.4 What Is Java? 9
1.5 Java ME 12
1.6 Why Use Java ME on Symbian OS? 17
1.7 Java’s Place in the Sun 21
1.8 Routes to Market 22
vi CONTENTS
1.9 Time for a Facelift 24
1.10 Back to the Future: MSA 2.0 and MIDP 3.0 24
1.11 Summary 26
2 Fundamentals of Java ME MIDP Programming 27
2.1 Introduction to MIDP 27
2.2 Using MIDlets 28
2.3 MIDP Graphical User Interfaces API 34
2.4 Non-GUI APIs in MIDP 56
2.5 MIDP Security Model 59
2.6 Networking and General Connection Framework 69
2.7 Using the Push Registry 78
2.8 MIDP and the JTWI 81
2.9 Mobile Media API 82
2.10 Wireless Messaging API 95
2.11 Symbian OS Java ME Certification 100
2.12 Summary 101
Part Two: Java ME on Symbian OS 103
3 Enter Java ME on Symbian OS 105
3.1 Running a MIDlet on a Symbian Smartphone 106
3.2 Which APIs Are Supported? 113
3.3 Proprietary JAD Attributes 122
3.4 Computing Capabilities of Java ME on Symbian OS 123
3.5 Java ME: Exposing the Power of Symbian OS 125
3.6 Tools for Java ME on Symbian OS 131
3.7 Java ME Management on Devices 131
3.8 Crossing to the Native Land of Symbian OS 139
3.9 Finding More Information 145
3.10 Summary 146
4 Handling Diversity 149
4.1 General Approaches to Handling Diversity 150
4.2 Detecting Diversity using Properties 151
4.3 Using Adaptive Code and Flexible Design to
Handle Diversity 153
4.4 Handling JSR Fragmentation 158
4.5 Handling Transitions Between Foreground and
Background 161
4.6 Supporting Diverse Input Mechanisms 162
4.7 Handling Diverse Multimedia Formats and
Protocols 166
4.8 Handling Screen and Display Diversity 169
CONTENTS vii
4.9 A Last Resort: NetBeans Preprocessing 173
4.10 Summary 173
5 Java ME SDKs for Symbian OS 175
5.1 Recommended Tooling Approach for Java ME on
Symbian OS 176
5.2 Generic SDKs: Java ME SDK 3.0 and WTK 2.5.2 177
5.3 SDKs for the S60 3rd Edition and 5th Edition
Platforms 178
5.4 SDKs for the UIQ 3 UI Platform 189
5.5 Summary 205
Part Three: MSA, DoJa and MIDP Game
Development 207
6 Designing Advanced Applications with MSA 209
6.1 What Is MSA? 209
6.2 What Can I Do with MSA? 213
6.3 Spicing up Legacy MIDP Applications 222
6.4 Beyond MSA 1.1: MIDP 3.0 and MSA 2.0 227
6.5 MSA and Symbian OS 229
6.6 Summary 230
7 DoJa (Java for FOMA) 231
7.1 In the Beginning. . . 231
7.2 DoJa – the Basics 234
7.3 I Love JAM 238
7.4 DoJa Basic Operations Manual 240
7.5 Eclipsing DoJa 240
7.6 Dirty Hands 243
7.7 A Safe Port 250
7.8 DoJa 5.1 Profile 254
7.9 Summary 264
8 Writing MIDP Games 265
8.1 What Is a Game? 266
8.2 Building a Simple MIDP Game 273
8.3 MIDP 2.0 Game API Core Concepts 279
8.4 Building an Advanced Java Game on Symbian OS 282
8.5 Summary 303
viii CONTENTS
9 Java ME Best Practices 305
9.1 Investing in the User Experience 305
9.2 Good Programming Practices 308
9.3 Streamlining the Deployment and Execution
Lifecycle 322
9.4 General Tips for Symbian OS 325
9.5 Summary 327
Part Four: Under the Hood of Java ME 329
10 Java ME Subsystem Architecture 331
10.1 Java Applications and Symbian OS 331
10.2 Application Management Software 336
10.3 MIDP Push 337
10.4 Mean and Lean Virtual Machine 338
10.5 MIDP Implementation Layer 342
10.6 Handling Asynchronous Symbian OS Operations 346
10.7 Java-level Debugging Support 348
10.8 Performance 349
10.9 Security 350
10.10 Summary 351
11 Integration of Java ME and Native APIs 353
11.1 Importance of Integration with Symbian OS
Services 354
11.2 Types and Levels of Integration 356
11.3 Integration Challenges, Costs and Considerations 357
11.4 Determining the Right Integration Style 358
11.5 Examples of JSR Integration 359
11.6 Summary 384
Appendix A: WidSets 385
Appendix B: SNAP Mobile 411
References 433
Index 435
Foreword
James Coplien
It was great re-discovering through this book just how much of a nerd I
am. Roy’s descriptions and exercises painted amazing pictures in my head
of the internal workings of my own Nokia S60 phone, to the extent that I
unearthed new and useful menus previously invisible to me. While I can’t
promise that every casual reader will find this book suitable as a user’s
guide, and while I can’t promise that every programmer will become an
expert user of their own handset by reading the chapters that follow, I can
promise the intent programmer a treasure chest of knowledge not only
for understanding what goes on inside your phone but also for changing
what goes on inside your phone.
Java ME on Symbian OS is a title that sounds like nerd’s heaven – and
it is (though it’s more than that, as I’ll come back to below). Though
the title bears two trade names, the meat of the book proudly displays
its inclusiveness across the market: Sun, Symbian, Nokia, Samsung, LG,
Sony-Ericsson, Motorola . . . It’s the ultimate mash-up. This is a book less
about niche technologies than about a broad phenomenon. It isn’t only
a technological phenomenon but a sociological one; if you don’t view it
that way today, I believe that vision is rapidly approaching tomorrow.
To the everyday programmer, I think this book will open a new
world of wonder, as history has similarly favored our industry several
times in the past. Twenty years ago, someone would have thought
you to be drunk if you asked him to take a picture of you with his
phone. Today we have lost touch with photographic film and, to a large
degree, with those ancillary devices called cameras. We used to have a
shelf-full of gadgets for voice dictation on the run, digital photography,
calendar management, and, yes, even communication – all of which are
x FOREWORD
converging on single small, convenient computers that are the brain-
grand-grand-grand-grand-children of Alexander Graham Bell. And those
boxes need software – software such as you will find in this book, along
with guidance for bringing it to life.
It was inevitable that the evolution of consumer programming should
turn to the telephone. I remember the visions of unification of computers
and telephones in the minds of people such as Jerry Johnson back in
Bell Lab in the 1970s. We can now look back at the past 20 years and
conclude that computers’ primary contribution to society has been not
as calculating engines in their own right, but as tiny points on an almost
fully-connected network that ties together most computers in the world.
The phone network is more than just a metaphor for the worldwide web:
it is often its backbone. As the pundits predicted, the intelligence has
evolved out of the network into its periphery, out of its bowels and into
its eyes, ears, and fingers.
The intelligence hasn’t stopped at phones. Next year, Nokia and RWE
are expected to market a box that extends the phone network to control
heating, window shades, and home security cameras. The possibilities are
endless. Programmable phones will replace not only cameras and small
dictation machines, but will reach ever further into both our immediate
and physically remote realities. They have already made a significant
foray into the video game space, taking advantage of advancing display
technology, complementing our newfound connections with reality with
newfound escapes into fantasy. In the not so distant future, these two
worlds may blend and merge. Whereas yesterday’s play was a personal
Tamagotchi and today’s play includes multiple Tamagotchis talking via
an infrared Tamacom protocol, tomorrow will see our phones as a
Tamagotchi interface whereby we feed or clean up after the flesh-and-
blood Fido back home – all with a sequence of a few DTMF tones.
Roy’s book takes us on a journey into a land that is more than
just nerd heaven. The history of computing has drawn more and more
everyday folk into programming. This trend sits squarely in the center
of the vision of people such as Alan Kay and Adele Goldberg: that
computers should be the sidekicks of human beings from early life,
enabling children of all ages to extend their memory and processing
power by manufactured, rather than biological, means. This vision of a
Dynabook – a truly personal computer, an extension of self – includes
information tethered to the outside world as one of its central building
blocks. Because my Dynabook is part of me, I get to program it. Today,
that programming means setting a date on my calendar or setting an
alarm for a meeting. Those humble acts may not entail using Java, but
FOREWORD xi
it’s still programming: as Dan Barstow used to say, ”No matter how
high-level, it’s still programming.” To me, as a C++ programmer, Java
looks almost like a scripting language. And that’s not even an insult.
Java has perhaps finally realized its vision of ubiquitous expression of
general-purpose computation that is portable and intelligible enough that
Everyperson can at least tweak the code. I know that such æsthetics
are difficult to judge from the seat of a professional programmer, but
we can at least say that Java code provides a glimpse of such a world.
Perhaps even my neighbor, the real-estate salesman, could read some of
the code in this book and understand it well enough to play with it. Or
my dentist. Or my banker. None of them are professional programmers.
But each has a computer on his or her desk: a machine which 40 years
ago would have terrified most secretaries, and which still terrifies some
executives today. Machine creatures inhabit more and more of the human
ecosystem.
It’s interesting to note that such programmability has played out not in
desktop phones (yes, they still exist) but in hand-held portable phones.
Why? Perhaps it is because only personal cellular phones are close
enough to our heart – or some other part of our anatomy – to truly be part
of Self. It was a revolution when people who bought the early Ataris and
Amigas discovered that they could actually program them themselves. We
are perhaps on the threshold of a revolution that unleashes more powerful
programming into the hands of what will be over one billion owners of
Symbian OS phones in two or three years. Even if great programmers arise
from only one in a million of these users of small-handheld computers
that take pictures, play games, and even place phone calls, it will be
enough to move the world.
This book, as a nerd’s text, is nonetheless a bold foray into Dynabook
territory. If nothing else, it will make you realize that if you own a
regular personal computer and a mobile phone, that it’s within your
reach – today – to write software that can be an at-hand extension of
yourself any time, anywhere. It is perhaps one small step on the road to a
future vision of even further integration between man and machine. Such
integration must go forward with intense ethical scrutiny and social care;
if we choose such a path, machines can make us even more human,
humane, and social than we are today.
I leave you with a poem which, when published, was wrongly
attributed to me alone. It was written by the attendees at VikingPLoP
2004 as we took the human–computer symbiosis to its limit. Think of
Java ME on Symbian OS as an important step on this journey. Nerds,
children of all ages, and everybody out there: Happy Programming!
xii FOREWORD
Comfortable as blue jeans
She fits.
Part of me, yet not me;
Unplugged: oxygen is her food
And the breeze her power adaptor.
Her identity mine, yet not me:
I put her down, I take her up
like a well-worn wallet plump
with life’s means and memories.
A thin mask worn in life’s play
And both of us are players.
I call her Self; she does not call me User
A curse unique to programmers and other pushers.
I and my computer are one
But we own each other not.
Envision this: my new machine, a soulmate,
With whom I talk in whispers unencumbered by flesh and bone
Software begotten, not made
Of one being with its person.
She hears my voice, and perhaps my thoughts
rather than the drumming of my fingers
that burdened her forebears:
35 calcium levers linking brain to digits,
slow and tired machines of the information age.
Now, mind to mind,
there for tea and sympathy
all day, and our night
minds together process the day,
sharing dreams – yet
She slumbers not, nor sleeps.
An invisible mask the birthright of all humanity;
Her software penned by
My soul
And like my soul, her hardware
Im-mortal, invisible
Us together wise.
Transparent personæ mine, yet not me,
That with me loves, and lives, and walks life’s journey –
A path both real and virtual at once
as only a True and rich life is.
FOREWORD xiii
With me she dies
– our immortality inscribed in
the fabric of the network.
No duality of community here
and Internet there –
The Network is the Com-
munity:
One Web of life.
Jim Coplien
Mørdrup, Denmark
2 July 2008
en.wikipedia.org/wiki/James O. Coplien
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Kicking Butt with Java Technology on
Symbian OS
Mobile phones have changed the lives of billions of people and it’s
clear that the revolution is just beginning. The quickly evolving world
of mobile technologies is an exciting place for developers to create new
applications to connect people and information.
Java technology has enjoyed dizzying success in just under a decade
in the mobile phone industry. As I write, more than 2.1 billion Java
technology devices are deployed worldwide. At the same time, Symbian
OS dominates the fast-growing smartphone market (with approximately
70%). This book is about the confluence of these two technologies and
how to create your own powerful mobile applications.
Now is a great time to be a mobile developer. You can help shape
the coming landscape of advanced mobile applications by harnessing the
power of both Java technology and Symbian OS. Learn the technologies,
let your imagination run free, and have fun!
Jonathan Knudsen
jonathanknudsen.com
Author of Kicking Butt with MIDP and MSA
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
About This Book
In 2001, Symbian published its first book devoted to Java on Symbian
OS. Jonathan Allin’s Wireless Java for Symbian Devices provided an
in-depth exposition targeted at programming PersonalJava on Symbian
OS. In 2004, Martin de Jode’s Programming Java 2 Micro Edition on
Symbian OS focused on programming MIDP, particularly MIDP 2.0 on
Symbian OS. This book is the third in the series and there is no longer a
need to explain what Java is. Therefore, the primary goal of this book is
not to teach Java programming but to introduce you specifically to Java
Platform, Micro Edition (Java ME) on Symbian OS.
This book covers various topics from different perspectives. Our
approach has been to start with the basics and prerequisites that are
assumed in the rest of the book, then zoom into Java ME on Symbian
OS specifically and then out again to discuss a few key areas of Java ME
development today. We finish the book by delving deep down to expose
what’s happening ’under the hood’.
The book logically divides into four main parts:
1. Introduction to Java ME and programming fundamentals
In Chapter 1, we describe the playground of Java ME on Symbian
OS. It is recommended reading if you are not familiar with Java
ME, Symbian OS or the smartphone industry. Chapter 2 is targeted
at developers with no experience in Java ME. It sets the baseline
information that is a prerequisite for reading the rest of the book,
which assumes a certain level of knowledge of Java programming
and, specifically, Java ME. Chapter 2 deals with the basic concepts
of a MIDlet, LCDUI, MMAPI, and so on.
xviii ABOUT THIS BOOK
2. Java ME on Symbian OS
Part 2 assumes you are familiar with Java ME but are interested
in learning about the Java ME platform hosted on Symbian OS.
Chapter 3 explains what makes Java ME on Symbian OS different
from other Java ME platforms; what makes it more powerful; and
what else is unique to Symbian smartphones. Chapter 4 provides
guidelines on how to handle differences between different Symbian
smartphones. Chapter 5 provides an overview of development SDKs
for Java ME on Symbian OS.
3. Drill down into MSA, DoJa and MIDP game development
Part 3 expands the discussion into various key areas of Java ME
development. We show how to leverage the power of MSA, give
an introduction to how Java evolved very differently in the Japanese
market, provide a glimpse of games development and equip you with
best practices for your next application.
4. Under the hood of Java ME
In Part 4, we reveal information that has rarely been exposed before.
Chapter 10 explains the internal architecture of the Java ME subsys-
tem as a Symbian OS component and Chapter 11 explains how Java
ME on Symbian OS is tightly integrated with the native services.
Appendix A introduces WidSets which is a run-time environment that
makes use of the Java language and the Java ME platform. Appendix B
introduces SNAP Mobile for game developers.
This book contains a number of web addresses. If any of them are bro-
ken, please consult the wiki page for this book at developer.symbian.com/
javameonsymbianos to find the updated location.
We welcome beginners and professionals, third-party application
developers and OEM developers working inside Symbian OS. Whether
you’re just starting out in the exciting world of mobile development, want
to learn Java ME or just like reading interesting stuff, this book is a mix of
different topics that combine in the same way as a dish full of spices.
Author Biographies
Roy Ben Hayun
Roy Ben Hayun has more than 10 years’ experience in various Java
technologies in various software engineering roles: engineer, consultant,
team lead, tech lead, and architect. He started his career in Lotus IBM,
working on JDK 1.1.8, and then became a founding member of eMikolo
networks, which pioneered P2P in the early days of Project JXTA. He later
worked in various roles in other startup companies in Java SE, Java ME and
Java EE. From 2002 until the end of 2007, he worked for Symbian, mostly
in the Java group working on the design and implementation of JSRs and
CLDC-HI VM tools support. In his last year at Symbian, he worked in the
team supporting developers, during which time he authored a number of
technical articles and white papers about run-time environments.
After JavaOne 2007, Roy joined Sun Microsystems. He is currently
working as a system architect in the Engineering Services group, which
leads the development, marketing and productizing of Java ME CLDC
and CDC on various platforms.
Ivan Litovski
Ivan joined Symbian in 2002, working first in the Java Team and later with
the System Libraries, Persistent Data Services and Product Creation Tools
teams. Ivan has 11 years of professional experience with Java, embedded
software, information security, networking, scalable servers and Internet
protocols. He enjoys solving difficult problems and research and devel-
opment. He has authored several patents and papers in peer-reviewed,
xx AUTHOR BIOGRAPHIES
international journals. He holds a BSc in Electronics and Telecommuni-
cations from the University of Nis, Serbia and is an Accredited Symbian
Developer.
Sam Mason
Sam spent about two years working on a Java-based, multi-lingual,
video-on-demand system for SingTel and other Asia-Pacific Economic
Cooperation (APEC) telecommunications agencies. He has spent most of
the last four years working with and learning about mobile phone tech-
nologies, while picking up a couple of Java certificates and completing a
Master of Information Technology (Autonomous Systems) at the Univer-
sity of New South Wales along the way. He was a contributing author
to Games on Symbian OS, writing the chapters on Java ME development
and DoJa. He is an Accredited Symbian Developer.
Daniel Rocha
Daniel is a software engineer with 10 years’ experience in application
development, having worked with web (Perl, ASP, PHP, JavaScript, JSP,
Flash), enterprise (Java EE) and mobile software (Symbian C++, Java ME,
Flash Lite, Python). He currently works as a Forum Nokia Technology
Expert.
Author’s Acknowledgements
I feel vividly that this project was an amazing experience, primarily
because of the people involved. I am blessed that there are so many
people to thank – editors, contributing authors, reviewers, test readers
and colleagues.
Two of the people whom I had the honor to be guided by, Jo Stichbury
and Jim Coplien, I met for the first time on the same day. The place was
the ACCU conference in 2006 and the idea of writing the next book about
Java ME for Symbian OS was too embryonic to be called ’an idea‘. Jo
Stichbury (who had just returned from Nokia to Symbian) knew from her
own authoring experience how to deliver a book from start to finish, and
I am thankful for her personal guidance, her professionalism and wisdom
as a technical editor, which has always managed to find the right solution
at any time and on any matter.
I am also thankful for meeting Jim Coplien, a truly visionary guy. Full
of passion, equipped with his one-of-a-kind way of thinking, he has that
rare long memory into the past of software engineering and a vision into
the future of what will come out of all that we are currently doing.
I am also in debt to the wonderful people who have contributed from
their knowledge and experience: Ivan Litovski, Sam Mason and Daniel
Rocha. Ivan has been a great friend from day one in the Java group at
Symbian, and is a reviewer and contributing author to this book. Sam
is a passionate mobile expert and the founder of Mobile Intelligence in
Australia. I have been lucky enough to work with Sam on this book and to
meet and become friends at JavaOne 2008. Daniel has constantly given
this project wonderful support and his contributions, from his viewpoint
inside Forum Nokia, have been invaluable. He came to the rescue on
many occasions, and I’m truly appreciative of his hard work and energy.
xxii AUTHOR’S ACKNOWLEDGEMENTS
I’d also like to thank Mark Shackman for the pleasure of working
with him during my four and a half years in Symbian. I am grateful for
his constant insistence on the build up of logical arguments and perfect
phrasing. Mark always delivers, and he manages to get the best out of
hundreds (by now probably thousands!) of embryonic articles and book
chapters.
Thanks also to Martin de Jode for his valuable comments from his own
experience in writing the second book in this series and much gratitude
to Satu McNabb for her support and for always being there to help.
I’d also like to acknowledge:
• the people at John Wiley & Sons for working with us on this book
with their high standards of professionalism and quality
• my current group, Engineering Services in CSG, Sun Microsystems,
which had the ability to see the future of Java from the remote distance
of the 1990s and leads the way towards the next generation of Java
technologies
• the Java group in Symbian, of which I had the pleasure to be a member
during most of my time in London
• the Developers’ Consulting team and the Developer Product Market-
ing team in Symbian
• the many people who took time and patience to read all the sugges-
tions and ideas that were yet to become chapters: Arnon Klein, Assaf
Yavnai, Yevgeny (Eugene) Jorov, Jonathan Knudsen, Tomas Brandalik,
Erik Hellman, Per Revesjö, Magnus Helgstrand, Lars Lundqvist, David
Mery, and Emil Andreas Siemes
• my parents and sister and all of my friends.
Finally, this book is for my friend, partner and wife – Gabi – and our
wonderful, beloved children, Noa and Ariel.
For being blessed with everything that has happened and the things
that are yet to happen.
I hope you will enjoy reading this book.
Symbian Press Acknowledgements
Symbian Press would like to thank Roy, Sam and Daniel for the hard
work and energy they’ve put into this book. Roy piloted this project with
particular passion, and the results you hold before you are testament to
his efforts and those he inspired in his co-authors. We were privileged
indeed to put together such a team of talented writers and developers,
and they in turn were fortunate to be able to draw on an extensive and
experienced support crew, including Sam Cartwright, Martin de Jode,
Ivan Litovski and Mark Shackman.
We’d like to thank everyone involved in writing and reviewing the
text of this book and in helping prepare the final manuscript. As usual,
we’re grateful to the Wiley team (Birgit, Colleen and Claire), and to Sally
Tickner and Shena Deuchars.
In particular, Jo would like to thank Antony and Bruce for supporting
the completion of this title.
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
Part One
Introduction to Java ME and
Programming Fundamentals
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
1
Introduction to Java ME, Symbian OS
and Smartphones
Symbian OS is the operating system that powers more than 70% of
smartphones worldwide. In addition to providing one of the industry’s
most powerful native platforms for after-market applications, Symbian OS
pushes the boundary further by allowing third-party software developers
to work with a wide variety of mobile technologies including Symbian
C++, Flash Lite, Python, POSIX-compliant C and, of course, Java ME – the
focus of this book.
The Symbian OS ecosystem has flourished over the last decade and,
like any success story, is made up of many parts. Handset manufacturers,
such as Nokia, use Symbian OS as the foundation stone of their user-
interface platforms. In Japan alone, Symbian OS powers over 30 million
phones that use NTT DoCoMo’s MOAP platform. The latest version,
Symbian OS v9, is used in almost all of Nokia’s famous Nseries (feature-
focused) and Eseries (business-focused) devices.
In this chapter, we explore the Java Platform, Micro Edition (Java ME)
technologies and see how they are uniquely positioned to address the
on-going mobile phone software revolution. We start with a look at
recent history, follow with a brief discussion of the Java language itself,
the composition of Java ME and the benefits it inherits from Symbian OS.
Finally, we wrap up with a look at the mobile phone market and get a
glimpse of what the future holds.
1.1 2003: Rise of the Mobile
One of the problems with turning points in history is that they’re often
only apparent in retrospect. Don’t expect to see Monday 16 June 2003
in any documentary about days that changed the world because it’s
not there – I checked. However, by the end of that day, a startling new
4 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
concept in mobile device hardware had been released, ushering in an
era of exponential progress in mobile computing.
On that rather special Monday, Nokia released a completely new type
of mobile phone. The Nokia 6600 was the most advanced mobile phone
anyone had seen, and it is still remembered today as a clear indication
of where the future was headed. It had a large, 16-bit color screen,
a four-way joystick for navigation and games, and a VGA, 640 × 480
camera for video recording and photography. The phone was a 2.5 G,
Internet-enabled GPRS phone running Symbian OS v7.0 s with 6 MB of
memory for storage, 3 MB RAM and had Bluetooth wireless technology
connectivity. It was also easy to use and looked great at the time (it looks
like a bit of brick today, as you can see from Figure 1.1).
Figure 1.1 Nokia 6600
This new device was clearly going to cause quite a stir, so the
Nokia marketing team came up with a special phrase just for the
launch – something that was prophetic and sounded really cool: Image is
Power.
Less important at the time but far more relevant to us today, the Nokia
6600 was the first mobile phone to come with the very latest in Java
technology – the Mobile Information Device Profile (MIDP) 2.0, which
had recently been finalized. Java ME was already dominating the mobile
software market; it was about to take a huge leap forward and the Nokia
6600 was the springboard. Even today, I keep my Nokia 6600 in a special
place and consider it with reverence.
In 2003, while the rest of the software industry was dragging itself out
of the Dot-com Bust, the constrained-device development sector was at
the start of a vertical rise. Hundreds of business applications had already
been written and shipped in expectation of an amazing shift in the way
people did business. The momentum for mobile hardware and software
2003: RISE OF THE MOBILE 5
built over the years following the release of the Psion Organiser 1 in
1984 and, by 2003, millions of portable information devices had sold
around the world. These included pagers, iPods and generic MP3 players,
personal organizers (both the original handheld computers and the latest
PDAs), Game & Watch1 devices and, of course, mobile phones.
People were getting busier and more ‘connected’. Business was becom-
ing more demanding, requiring decisions faster, for higher stakes, and
24 hours per day. It was an exciting time and mobile technology, it
seemed, had all the answers. Except that it didn’t work out that way.
What the oracles didn’t predict was that while there would be a
worldwide explosion in the use of mobile phones, they would largely be
used to send text messages, buy ringtones and wallpapers, and take photos
or video. People didn’t buy them to do business after all. They bought
them as personal statements and as fashion accessories. They bought
them as a convenient communications device. They also bought games.
Quite a lot of games, actually. Thousands of titles were developed and
sold directly to the public or shipped on devices. The market for mobile
phone games quadrupled between 2002 and 2003 and it is estimated that
over 50 million phones that allow after-market game installation were
shipped in 2002 alone.
Fast forward five years to 2007 and there are nearly three billion mobile
phone subscribers worldwide.2
The mobile phone has now become the
personal information accessory of choice – everyone is ‘texting’ using
appalling new pseudo-grammars (wch is gr8 if u cn do it), crowded buses
sound like call centers, the mobile games market has exploded into the
public eye with huge titles, such as The Sims 2,3 and in many parts of
the world a new kind of digital life has emerged and become the norm.
The newest devices are a far cry from the Nokia 6600. January 2007 saw
the iPhone launched into the marketplace, followed closely by the Nokia
N95 in March of the same year with the slogan ‘It’s what computers have
become‘. In October 2008, the T-Mobile G1 became the first smartphone
to use the Android platform. Clearly innovation and demand caused
many changes in just those five years!
Let’s look at some of the figures to put this into perspective – in 2007,
mobile handset annual sales exceeded 1 billion units for the first time.
That means that more than 2.7 million phones were sold each day.
Moreover, sales of Nokia handsets alone in 2007 were larger than the
entire industry in 2001 and 2002! Figure 1.2 charts annual sales and
shows how the market almost tripled over a six-year period, with an
annual growth rate of nearly 20%.
1 If you missed the 1980s, find out about the Game & Watch craze at en.wikipedia.
org/wiki/Game %26 Watch
2
Global cell phone penetration reached 50% in November 2007, according to
www.reuters.com/article/technologyNews/idUSL2917209520071129
3 www.thesims2.com
6 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
00
200,000
Sales
(000s)
400,000
600,000
800,000
1,000,000
1,200,000
Nokia Motorola Siemens Samsung Sony Ericsson LG Others
Figure 1.2 Annual number of devices sold4
Add five more years and it is 2012. At current growth rates, it is
estimated that smartphones will comprise nearly 30% of the market
(compared to 10% in 2007) and that subscriber levels worldwide will
reach 3.5 billion. Just think about that number – we can’t really conceive
figures like this in our minds, but this is a really big market. Eight out
of ten devices support some form of Java-based technology – quite an
opportunity for the budding technically-minded entrepreneur. If you sell
every thousandth person a $1 Java ME MIDlet, pretty soon you’ll have
made over $3 million – job done, time to retire.
1.2 2008: Mobile Generation
Our world has changed. Like all great upheavals, the ‘rise of the mobile’
has had both positive and negative effects on us. As a society, we’re
irrevocably addicted to our information devices now. Everywhere we look
we see iPod MP3 players, Tom-Tom personal navigation devices, mass-
market feature phones, smartphones, managers who can’t get off their
Blackberries, people talking while walking, people setting up meetings,
messaging, listening to music, reading, using devices for entertainment,
organization, romance, learning. It goes on and on.
Mobile information devices are the instruments of an unprecedented
wave of fundamental social change. The very basis upon which we inter-
act with each other has suddenly changed without notice and the results
are not necessarily all good. SMS bullying is on the rise; onboard cameras
have changed our expectations of personal privacy; train carriages are
4 java.sun.com/developer/technicalArticles/javame/mobilemarket
MEET THE HOST – SYMBIAN OS 7
like mobile offices; and I’ve yet to go to a funeral where someone’s mobile
doesn’t ring during the eulogy. It’s fashionable to talk about people being
more ‘connected’, as I did above, but a world full of people with iPods
and earphones can feel like an increasingly isolated one. Even our basic
standards of interaction are affected – people think nothing of sending
text messages while talking to you and the legalities involved with using
evidence from mobile phones are still being ironed out.
On the positive side though, the plethora of lifestyle applications and
services available on mobile phones now definitely makes life a lot more
interesting. GPS and navigation applications make it hard to get lost in
most places in the world and you can send goodnight kisses to your kids
via MMS from wherever you end up! Messaging is by nature asynchronous
so you don’t have to deal with inter-personal communication immediately
any more, which allows you to manage your time better. And if you have
a two-hour train trip to work why not listen to a podcast on some topic of
interest instead of reading the newspaper?
I was thinking the other day about the phrase ‘Information is power’
and about mobile phones, games, Symbian OS, business applications,
Nokia, the future, mobile phones (again), robots, Linux and just general
technology. As sometimes happens, I had an acronym attack and real-
ized that information is indeed POWER because it affords us Pleasure,
Opportunity, Wealth, Experience and Reputation. To me, this acronym
spells out five very good reasons to start learning Java ME today. If you’re
not yet convinced, stick with me, since the rest of this chapter, and
the book, considers the use of Java technology, specifically the Java ME
platform, as the candidate to address the growing hardware diversity and
the challenges of the future.
1.3 Meet the Host – Symbian OS
Symbian OS is a market-leading, open operating system for mobile
phones. Cumulative sales of Symbian smartphones reached 226 million
units worldwide in June 2008. By the end of that month, more than 250
different models of smartphone had been created by handset manufactur-
ers licensing Symbian OS; eight handset vendors, including the world’s
five leading vendors, were shipping 159 mobile phone models.5
On 24 June 2008, the Symbian Foundation was announced6 and,
at the time of writing, it is on track to create an open and complete
mobile software platform, which will be available for free, enabling
the whole mobile ecosystem to accelerate innovation. The Symbian
Foundation provides, manages and unifies Symbian OS, S60, MOAP(S)
and UIQ for its members. It is committed to moving the platform
5 www.symbian.com/about/fast.asp
6 www.symbian.com/news/pr/2008/pr200810018.asp
8 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
to open source within two years of the Foundation’s announcement.
See www.symbianfoundation.org for more information.
There have been many operating systems available over the last
decade – so what is it about Symbian OS that has enabled it to stay so far
ahead of the competition? The design of Symbian OS is highly modular,
which means that it is constructed from well-defined, discrete parts. Most
Symbian OS components expose a Symbian C++ API7
and a large number
of these APIs are available to third-party application developers.
At a high level, Symbian OS can be thought of as a layered model, with
a flexible architecture that allows different UI layers to run as platforms
on top of the core operating system. That is, Symbian OS provides a
framework that supplies a common core to enable custom components
to be developed on top of it. The generic UI framework of Symbian
OS supplies the common behavior of the UI and supports extension
by licensees who define their own look and feel. For example, the S60
platform, supplied by Nokia, sits on top of Symbian OS. S60 is the world’s
most popular smartphone platform, and is currently used by Nokia, LG
and Samsung. Almost 180 million S60 devices had been shipped by S60
licensees by the end of June 2008.8
The power and configurable design of Symbian OS are the key con-
tributing factors to its success. Today, Symbian OS devices are being
sold in every market segment as you can see from the variety of
hardware shown in Figure 1.3. If you want to find out more about
Symbian and Symbian OS, there are a range of resources including books
from Symbian Press, available from developer.symbian.com/books, and
www.forum.nokia.com. If you are new to Symbian OS and interested in
a slightly more detailed overview about Symbian OS, a recommended
resource is the first chapter of [Babin 2007].9
Walkman®
Sport
Remote
Control
Music
Multimedia
Waterproof
Mobile
TV
Biometrics
Hybrid
Business
Music
Fashion
Imaging
Simple
Figure 1.3 Symbian OS is everywhere
7 Symbian C++ is a dialect of C++ with idiomatic extensions.
8
www.forum.nokia.com/main/platforms/s60
9 The chapter can be downloaded from developer.symbian.com/main/documentation/
books/books files/dasos.
WHAT IS JAVA? 9
1.4 What Is Java?
Let’s jump back to August 1998. The word ‘Java’ is synonymous with the
Internet in the public mind. The most common question at the time is
‘What is Java?’ If you can explain that then you have a job.
The company behind Java technology is Sun Microsystems, which was
founded in 1982 and today provides a diversity of software, systems,
services, and microelectronics that power everything from consumer
electronics, to developer tools and the world’s most powerful data centers.
Other than Java technology, the core brands include the Solaris operating
system, the MySQL database management system, StorageTek10 and the
UltraSPARC processor.
In the early 1990s, Sun formed the ‘Green Team’ whose job it was
to prepare for the future. One of the team members was James Gosling
(known as ‘the father of Java’). The aim was to create a software platform
that could run independently of the host platform – and the ‘Write Once
Run Anywhere’ mantra was created. By creating a controlled virtual
environment, or machine, software written on one hardware platform
could run unaltered on any other hardware platform.
The Java programming language was introduced by Sun Microsystems
in 1995 and is designed for use in the distributed environment of the
Internet. It was designed to have familiar notation, similar to C++, but
with greater simplicity. The Java programming language can be character-
ized by:
• Portability: Java applications are capable of executing on a variety of
hardware architectures and operating systems.
• Robustness: Unlike programs written in C++, Java instructions cannot
cause a system to ‘crash’.
• Security: Features were designed into the language and run-time
system.
• Object orientation: With the exception of primitive types, everything
in Java is an object in order to support the encapsulation and message-
passing paradigms of object-based software.
• Multithreading and synchronization: Java supports multithreading and
has synchronization primitives built into the language.
• Simplicity and familiarity: This is, of course, relative to C++. Don’t
imagine that Java can be learned in a day.
Java is a technology rather than just a programming language. It is a
collection of software products and specifications that provide a system
10 StorageTek is a tape-based storage solution from Sun. See www.sun.com/storagetek
for more information.
10 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
for development and deployment of cross-platform applications. After
you’ve worked with Java technologies for a while, you’ll realize that
they’re also much more than that – they’re a way of thinking about
software systems and how they work together.
Java is an interpreted language. This means that program code (in
a .java source file) is compiled into a platform-independent set of
bytecodes (a .class file) instead of into machine-specific instructions
(which is what happens to a C program). These bytecodes are then
executed on any machine that hosts a Java platform, a software-only
platform that runs on top of a native platform (the combination of an
operating system and the underlying hardware). A Java platform is divided
into two components:
• The Java virtual machine (JVM) that executes the Java language
bytecode can be ported to various native platforms.
• The collection of Java APIs are ready-made software libraries that
provide programming capabilities.
Together, the JVM and the APIs form the Java platform which insulates
an application from the native platform.
This was a remarkable achievement but it was not achieved without
cost. Support for low-level power and fine-grained control was sacrificed,
as well as explicit memory management and pointers. It was almost
impossible to write Java software that would corrupt memory, but pro-
grammers couldn’t dispose of memory themselves (to the horror of many
there was a new keyword but no delete); instead it was handled auto-
matically by the run-time environment using the ‘garbage collector’. This
was part of the environment that monitored object references at run time
and would decide when to reclaim allocated memory on behalf of the
program.
Added to all of these new ideas was the ‘applet’. This probably had
the largest role in making Java a 1990s buzz word. Java applets are small
programs that can run inside a web browser. Code resides on a remote
server, is downloaded over the network and is executed locally inside a
‘sandbox’, restricting operations to those considered ‘safe’. At the same
time, class file verification and a well-defined security model introduced
a new level of software security.
Java applets had limited use and were quickly outdated by the rise of
Flash as a browser-based, client-side technology but applets had served
a special role in the Java world. They demonstrated the power of this
new language called Java, raised awareness of the Internet and helped
create a strong worldwide Java developer base that today numbers over
six million.
As time went on, Java moved to have more of a focus on desktop
applications and then server applications: suddenly, everyone was talking
WHAT IS JAVA? 11
about Enterprise Java Beans. Following this was a big leap to smart cards
and the emerging market with the rise of mobile phones.
Sun quickly realized that while there were Java solutions for all of
these areas, no one set of technologies could adequately address all
requirements. It was at this point that Java was separated into the four
core technologies that we see in Figure 1.4.11
Optional
packages
Servers &
enterprise
computers
Servers &
personal
computers
High-end PDAs,
TV set-top boxes &
embedded devices
Mobile
phones &
entry-level
PDAs
Smart
cards
Optional
packages
Optional
packages
Optional
packages
MIDP
Java Platform, Micro Edition (Java ME)
CLDC
JVM
CDC
Java
Card
Card VM
JVM
JVM
JVM
Foundation Profile
Java 2
Platform,
Enterprise
Edition
(Java EE)
Java 2
Platform,
Standard
Edition
(Java SE)
Personal Profile
Personal
Basis
Profile
Figure 1.4 Java technologies
The Java Platform, Micro Edition (Java ME) fork was created to address
the constrained-device market. Java Card is a separate technology that
has nothing to do with Java ME. These days, most mobile phones include
some kind of Java technology. Blackberries run a superset of Java ME,
extended with RIM libraries. Google’s Android platform uses a ‘Java-like’
platform and even Microsoft’s Windows Mobile and Pocket PC support
Java ME. Nokia’s Series 40 phones, which form the backbone of the
feature phone market, all have support for Java ME as do all phones
running Symbian OS.12
If you want to know more about the other Java technologies or learn
about the Java language, this is probably the wrong book for you. If that’s
what you want, then probably the best place to start learning about Java
11
Java ME consists of two ‘flavors’, which is why there are five groups in Figure 1.4.
12 Except for MOAP(S), which has DoJa; it is very similar to Java ME, but is not strictly the
same.
12 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
is straight from the creator himself, James Gosling in [Arnold, Gosling
and Holmes 2005]. From this point on, we’re only going to talk about
ME – Java ME!
1.5 Java ME
Sun launched a research and development project called Spotless in the
1990s in order to produce a JVM that could run on devices with small
memory and power budgets, intermittent or non-existent connectivity,
limited graphical user interfaces, divergent file system concepts (if any)
and wildly varying operating systems. This could be anything from set-top
boxes to Internet phones, parking meters, digital TVs, vending machines,
automotive interfaces, electronic toys, personal organizers, household
appliances, pagers, PDAs, high-end smartphones and mass-market feature
phones.
The result of the project was the Kauai virtual machine (KVM). This
was a cut-down version of the JVM that required less than 10% of
the resources needed for the desktop standard edition of Java. This was
achieved by targeting the size of the virtual machine and its class libraries,
reducing the memory used during execution and by creating a pluggable
architecture that allowed sub-systems of the KVM to be tailored to specific
device architectures.
With such a diverse range of hardware targets, it was decided to
adopt a more flexible model for Java ME and the final result consisted of
three high-level components that together make a wide range of solutions
possible. Java ME consists of:
• configurations
• profiles
• optional packages.
We’ll look at each of these in detail shortly. In order to allow for future
expansion and new technologies, additions to the Java ME technologies
are managed through the Java Community Process13 in the form of Java
Specification Requests known as JSRs. Each JSR is reviewed by panels
of experts and public drafts allow a wide range of interested parties to
contribute to the process. JSRs are usually referred to by their name and
number; for example, JSR-82 is the specification request for the Bluetooth
API.
A lot of functionality had to be removed from the desktop Java Standard
Edition (Java SE) to make Java ME. For example, some things that are
missing include:
13 www.jcp.org
JAVA ME 13
• reflection
• thread groups and advanced thread control
• user-defined class loaders
• the Java native interface (JNI)
• automatic object finalization.
Compatibility played a large part in the design of Java ME. In order
to maintain as much compatibility with Java SE as possible, the Java
ME packages were divided into two logical groupings: those that were
specific to Java ME (packages whose names start with javax) and those
that were a subset of their Java SE counterparts which followed the same
package-naming convention.
One of the strongest features of the Java language is its security – both
at the application layer and within the virtual machine itself. The VM
security layer ensures that bytecodes are valid and safe to execute. This
works really well on servers and the desktop environment but not so
well on mobile phones with small processors and small power and
memory budgets. The solution was a hybrid approach using the concept
of pre-verification performed offline as part of the build process on the
development machine. Only after VM acceptance may the bytecodes
execute on the host hardware.
1.5.1 Configurations
Configurations define the lowest common denominator for a horizontal
category of devices that share similarities in terms of memory budgets,
processor power and network connectivity. A configuration is the spec-
ification of a JVM and a base set of necessary class libraries which
are primarily cut-down versions of their desktop counterparts. There are
currently only two configurations:
• The Connected Limited Device Configuration (CLDC) was aimed
specifically at mobile phones, two-way pagers and low-level PDAs.
• The Connected Device Configuration (CDC) was aimed at devices
with more memory, better network connectivity and faster processors.
We should be clear, however, that the CDC profile doesn’t really
have a role in the mobile phone space at this time. Although high-end
devices, such as Symbian OS phones, can accommodate a CDC-based
Java platform, the consumer market today is based on MIDP/CLDC
applications, so CDC is not within the scope of this book.
14 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
Table 1.1 CLDC 1.1 Packages
Package Description
java.io Basic classes for I/O via data streams, Read-
ers and Writers
java.lang Reduced math library, threads and system
functionality, fundamental type classes
java.lang.ref Support for weak references which allows
you to hold a reference to an object even
though it is garbage collected
java.util The Vector and Hashtable classes, basic
date and calendar functionality and a
pseudo random number generator which
is great for games
javax.microedition.io CLDC specific interfaces and factories for
datagrams, connection stream etc. Imple-
mentation deferred to profiles.
So far there have been two versions of the CLDC,14 the latest being
CLDC 1.1. Most mobile phones shipped since 2003 contain version 1.1
of the CLDC. CLDC 1.1 (see Table 1.1) includes, amongst other updates,
support for floating-point operations with the introduction of the Float
and Double classes, thread naming and interrupts. The total minimum
memory requirement was also lifted from 160 KB to 192 KB.
While the discussion so far has focused on mobile phones, the CLDC
is not just for phones. As we’ll see in the following section, it forms the
foundation for a number of profiles that target completely different device
families.
1.5.2 Profiles
Profiles sit on top of a configuration and allow it to be adapted and
specialized for a particular class of devices in a vertical market such
as mobile phones. A profile effectively defines a contract between an
application and a set of devices of the same type, usually by including
class libraries that are far more domain-specific than those available in
any particular configuration.
Figure 1.5 shows the three profiles that currently extend the CLDC. The
Mobile Information Device Profile (MIDP) is most relevant to our work
here; the Information Module Profile15
(IMP) targets small devices that
may have no user interface at all, such as parking meters, call boxes, and
14
See the white paper at java.sun.com/j2me/docs/pdf/CLDC-HI whitepaper-February
2005.pdf .
15 java.sun.com/products/imp/index.jsp
JAVA ME 15
Mobile Information
Device Profile
Information
Module Profile
CLDC
Digital Set Top
Box Profile
Figure 1.5 CLDC profiles (adapted from [Ortiz 2007, Figure 5])
vending machines; and the Digital Set-Top Box Profile is aimed squarely
at the cable television market.
CLDC is also used by the proprietary DoJa profile for i-mode devices
from NTT DoCoMo, which dominates over 50% of the Japanese market.
We talk more about DoJa in Chapter 7.
Applications that use the MIDP libraries are called MIDlets. MIDP
defines the core functionality that mobile applications can leverage (for
example, the user interface (UI), local storage and network connectivity)
and also specifies application lifecycle management. The original version
of MIDP was started in November 1999; even though it did not specifically
provide libraries for games, that didn’t stop hundreds of titles being written
and sold worldwide. In fact, so successful was MIDP 1.0 that work began
in 2001 on defining the second version – MIDP 2.0.
The MIDP 2.0 libraries include a high-level UI API with support for
standard widgets (textboxes, check boxes, buttons, etc.) and a low-level
UI API supporting graphics contexts aimed mainly at games develop-
ment. The low-level API includes standard routines for creating graphics
primitives (lines, polygons, arcs, etc.) as well as supporting clipping,
full-screen canvases, regions, image manipulation, fonts, brushes, colors,
and off-screen buffers. Support for local persistence on the MIDP is pro-
vided through the record management system (RMS). The CLDC Generic
Connection Framework was extended with additional connections, such
as HTTP, TCP and UDP.
MIDP 2.0 also introduced timers, the Media API (a subset of the
optional JSR-135 Mobile Media API) and the Game API package which
enables the development of rich gaming content for mobiles.
1.5.3 Optional Packages
The optional general-purpose APIs provide a set of functionality that is
not specific to any particular class of devices and have allowed the Java
ME platform to evolve and embrace emerging technologies. They add
extra functionality to a profile and are sometimes incorporated into the
profile as the technology matures. The Mobile 3D Graphics for J2ME API
(JSR-184) and the Location API (JSR-179) are good examples of optional
packages. It is common to simply use the term ‘JSR’ when referring to
16 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
the set of packages a device may support, although configurations and
profiles are actually all the product of particular JSRs.
Java ME got off to a bumpy start – the realities and pressures of
business competition, largely due to the phenomenal rise of the mobile
games industry, led to a wide disparity in optional JSR support across
the set of available devices in the market. There was no standard set of
JSRs available, some implementations didn’t comply with the defined JSR
requirements and some only offered partial compliance; it was extremely
difficult even to find out which JSRs were supported on any particular
handset. Sometimes irregularities occurred within the same family of
mobile phones from the same manufacturer, with APIs missing for no
obvious reason. Manufacturers would also add their own proprietary
APIs to allow non-standard functionality or extra functionality that wasn’t
covered by the standard JSRs. While that addressed the short-term need,
such libraries had to stay around for compatibility reasons long after they
had been superseded.
The net result was a series of device-specific workarounds leading to
complex code forks and build trees for Java ME applications – particularly
games which would typically target hundreds of handsets at any one time.
Game development houses wrote entire libraries trying to work across
these heterogeneous environments and then had to work to recoup the
investments made. This unfortunate phenomenon is known as ‘fragmen-
tation’ and the ‘write once, run anywhere’ mantra became ‘write once,
debug everywhere’. This had an extremely detrimental effect on the time
to market of Java ME applications and games.
1.5.4 Tackling Fragmentation
Something had to be done. The first attempt to tackle fragmentation
was JSR-185, Java Technology for the Wireless Industry (JTWI), which
specified a minimal level of optional API support for JTWI-compliant
devices. Release 1 of the JTWI was approved in July 2003 and defined
three categories of JSR: mandatory, conditionally required, and minimum
configuration. A handset that declares itself to be JTWI-compliant has
CLDC 1.0 or CLDC 1.1 as a minimum configuration and must support at
least:
• MIDP 2.0 (JSR-118)
• Wireless Messaging API (JSR-120).
If the device allows MIDlets to access multimedia functionality via
APIs, then the JTWI also specifies that the Mobile Media API (JSR-135) is
required (i.e., it is conditionally required).
JTWI also defined a number of implementation parameters for these
JSRs, including support for JPEG encoding, MIDI playback, the number of
WHY USE JAVA ME ON SYMBIAN OS? 17
record stores allowed in the RMS, Unicode support and some threading
requirements. While this was a great start, more needed to be done. JTWI
served as a necessary consolidation point in the evolution of the mobile
industry, but there were still many JSRs in the world of Java ME.
The Mobile Services Architecture16
(JSR-248, MSA), finalized in
December 2006, mandated that an MSA-compliant device is JTWI-
compliant and implements a much wider range of JSRs. The specification
defines two categories of MSA, known as Full MSA and MSA Subset (see
Figure 1.6).
(a) (b)
Figure 1.6 Mobile Services Architecture: a) Full MSA and b) MSA subset (adapted from
[Ortiz 2007, Figure 3])
MSA is a huge step forward and the number of MSA-compliant devices
available in the market is increasing all the time. Have a look at the Java
ME device registry at Sun, which lists some of them, to see how MSA has
raised the bar. (For more information on MSA, see Chapter 6.)
1.6 Why Use Java ME on Symbian OS?
Why not just use Symbian C++? That’s a good question. To answer it, we
need to look firstly at what people do with their smartphones and then
how it is achieved technically.
16 jcp.org/en/jsr/detail?id=248
18 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
web surfing once a day
primary camera
primary MP3 player
download music
willing to pay for mobile TV
% mobile users 0% 10% 20% 30% 40% 50% 60% 70% 80%
Figure 1.7 Smartphone usage17
Figure 1.7 shows the results of a survey of how people are willing to
use their smartphones. In addition, if we were to ask a random sample
of people in the street what they do regularly, we’d also expect them to
include activities such as playing games, sending text messages, sending
pictures, social networking, checking match scores, finding directions,
watching videos, checking weather or traffic – and annoying other people
on buses.
It is clear that there are many uses for smartphones, most of which
involve downloading mobile content, such as installable applications and
games, purchasing multimedia, such as music, videos, and mobile TV,
or simply downloading web pages while browsing the Internet. ‘Content’
is the key word here. A high-end mobile platform cannot exist without
content; in its absence there’s nothing that compels the user to buy a
high-end device. Who would buy a fully featured smartphone to make
voice calls and send SMS messages only?
In theory, it is possible to restrict all installable content to that created
using Symbian C++, in order to control where it comes from. That just
results in a ‘walled garden’, which goes against the principle of Symbian
OS as an open platform, because millions of talented engineers who are
not well-versed in Symbian C++ cannot contribute to the platform and any
existing content not written in Symbian C++ cannot be reused. That would
be unduly limiting, so the Symbian strategy is to enable environments
that maximize third-party developer contributions and content re-use.
Apart from Java ME, the other run-time environments available include
POSIX-compliant C, Flash Lite, Silverlight, Python, Ruby, Web Runtime,
and WidSets.18
So a better question is ”when should I use Java ME on a highly powerful
and open environment, such as Symbian OS?”. To work out the answer to
17
‘Welcome to the Smartphone Lifestyle’ by Nigel Clifford CEO of Symbian Ltd, Symbian
Smartphone Show, 2007 keynote address
18 developer.symbian.com/main/documentation/runtime environments
WHY USE JAVA ME ON SYMBIAN OS? 19
that question you need to do a cost–benefit analysis which covers areas
such as the available skills in your organization, functional feasibility in
Java, development effort in Java compared to other options, performance
considerations, and cross-platform requirements, all framed by the profile
of your application.
Let’s take a quick look into how the ‘leading Java platform’ strategy
translates into technical support. The Symbian implementation of the Java
ME technology platform is best of breed, so we’ll run through some of the
benefits that Java ME enjoys under Symbian OS.
Optimized Performance
The most common criticism leveled at Java ME (or any version of Java) is
that it doesn’t execute as fast as native code because it’s an interpreted
language (in principle, the JVM interprets Java bytecodes at run time). This
is mentioned so often, you’d think that everyone was writing real-time
satellite control systems instead of games for mobile phones. Java runs
much faster than it used to: the KVM was placed in the Java museum
long ago. Symbian replaced the KVM with CLDC-HI HotSpot, in which
the application bytecode is compiled to the ARM instruction set on the
fly. As a result, Java applications received a major performance boost
that was not only measurable by objective benchmarks but also by the
user – which is the real benchmark in most mobile applications.
No Hard Limits on Computing Resources
On most feature phones, the memory assigned to Java is fixed when the
device is created, which causes a wide variety of challenges for advanced
application development on these platforms. Symbian OS does not place
arbitrary constraints on available memory, storage space, number of
threads, number of connections, or JAR size. Within the bounds of
available resources, there are no limits – the heap can grow and shrink
as required.
Consistency and Variety of JSRs
Probably the greatest benefit of working with Java ME on Symbian OS is
the consistency and variety of JSRs. The problems of JSR fragmentation are
largely a thing of the past. The set of optional JSRs supported has grown
with each new version of the operating system and the latest smartphones
expose some of the very latest in technology directly to MIDlets.
With this wide variety comes both implementation consistency and the
ability to leverage the best of the operating system. For example, releases
of Symbian OS v8.0 and later support the full Mobile Media API (JSR-135)
and provide native support for OpenGL ES 1.0 (an abstraction layer for
the Mobile 3D Graphics API (JSR-184), meaning that your MIDlets auto-
matically benefit from hardware acceleration on the handset). Symbian
20 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
Table 1.2 JSR Support on Symbian OS
JSR Nokia 6,600 Nokia N70 Nokia N96
Symbian OS version v7.0 s v8.1a v9.3
Release Date 16 June 2003 27 April 2005 11 Feb 2008
CLDC 1.0/1.1 1.0 1.1 1.1
MIDP 2.0/2.1 2.0 2.0 2.1
Bluetooth 82 ✓ ✓
Mobile Media (MMAPI) 135 ✓ ✓ ✓
Wireless Messaging 120 ✓ ✓ ✓
Wireless Messaging 20519 ✓
File and PIM 75 ✓ ✓
Mobile 3D Graphics (M3G) 184 ✓ ✓
JTWI 185 ✓ ✓
Web Services 172 ✓ ✓
Location API 179 ✓
Security and Trust Services 177 ✓
SIP API 180 ✓
Scalable 2D Vector Graphics 226 ✓
Advanced Media Supplements 234 ✓
MSA 248 MSA Subset
OS v9 enhances a number of existing APIs and adds many more. The net
result is a rich diversity of functionality optimized for performance and
memory efficiency. Table 1.2 shows a snapshot of how JSR support under
Symbian OS has evolved over the last few years.
Summary
When you develop using Java ME and Symbian OS, you are combining
the world’s leading smartphone operating system with the most successful
mobile phone development platform to date. Symbian OS brings consis-
tency, performance, reliability and variety to its Java ME offering while at
the same time removing the most common limitations of other operating
systems.
19 JSR-205 was an update to JSR-120 that added programmatic support for MMS.
JAVA’S PLACE IN THE SUN 21
There are an enormous number of Java ME applications already out
there – far exceeding the number of native Symbian C++ applications
ever built. The number of Java developers for the mobile environment
is also increasing and is undoubtedly bigger than the army of Symbian
C++ developers.
Having said all this in praise of Java ME, do keep in mind that there are
times when you need to go native, times when you need the maximum
speed, real-time performance, fine-grained control or bare-metal access
to native services that are not exposed in Java. When you need low-
level power, tight integration with the operating system, or advanced
features that are not scoped by Java, then your best option is probably
Symbian C++. For example, Symbian OS native services allow you to
develop hooks into the TCP/IP stack and plug extensions to the Symbian
OS Messaging component. Java ME is simply not designed for such
requirements. For a further comparison of native Symbian C++ and Java
ME on Symbian devices, please see [Mason and Korolev 2008].
1.7 Java’s Place in the Sun
There can be no discussion of Java ME without a section about mobile
games. This is such a booming and exciting industry that Symbian has
already published an entire book just on mobile game development
[Stichbury 2008].
Almost as soon as the first Java-enabled handsets reached the public,
the mobile games explosion was under way. While MIDP 1.0 was a
fantastic start, it was the release of MIDP 2.0 with its Game API that
really made the difference. Suddenly, there was a GameCanvas class,
support for basic sounds via tone generation, support for sprites and
collision detection, the ability to take over the entire screen and efficient
mechanisms for representing large animated backgrounds and detecting
multiple keystrokes during the main game loop.
It was pretty clear that mobile games were out-selling every other
type of application across all platforms and the pace was accelerating. A
new type of gamer emerged who was very different from the traditional
hard-core console jockeys. They didn’t sit in darkened rooms eating pizza
and pretending to be someone else online – instead people played games
on their mobiles while waiting for a bus, walking around or just sitting in
a park. In a major research project for N-Gage,20 one of the key findings
was that mobile games were played almost as much on the move and
when waiting as when at home.
In this market, games needed to be designed to be played in short
bursts, to be paused and re-started without warning, to deal with sudden
20 ‘Evolution of Mobile Gaming’, available from Forum Nokia (www.forum.nokia.com).
22 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES
loss of battery power or to be interrupted by an incoming call. Ad-hoc
networks could be created with Bluetooth wireless technology for multi-
player games and, with the introduction of the Mobile 3D Graphics API
(JSR-184,21 also known as M3G), artists and designers could create game
assets using industry-standard 3D modeling tools and developers could
include and animate them in 3D scenes on actual handsets. On Symbian
OS phones, the M3G implementation leverages the native support for
OpenGL ES that comes with the operating system.
Of course there were problems. Mobile phones, even high-end ones,
have limited power, memory, processing and screen area. Floating-point
operations present a significant hurdle to be overcome when trying to
perform 3D graphics calculations on a phone. It was quickly apparent
that JSR-184 could not provide acceptable frame rates in the absence of
hardware acceleration.
Now that a few more years have passed, it’s pretty common to see
mobile phones with dedicated hardware for graphics and floating-point
calculations and the latest Symbian OS phones natively support OpenGL
ES 1.1. The introduction of OpenGL ES 2.0 will change the entire mobile
gaming landscape; it has support for the programmable graphics pipeline
(i.e. shaders) and there is already a JSR in progress to work with it – the
Mobile 3D Graphics API 2.0 (JSR-297).22
Realizing that mobile multiplayer game-play was a huge potential mar-
ket, Nokia launched the Scalable Network Application Package (SNAP)
framework23 in 2003. Network operators love it because it generates
revenue by increasing bandwidth usage. SNAP 2.1, the latest version of
the SDK, has only just been released at time of writing; it is discussed in
Appendix B. We also discuss general games development in more detail
in Chapter 8.
1.8 Routes to Market
So you bought this book, learned all about Java ME application devel-
opment, designed and built the killer Java ME mobile application and
you’re ready to sell – now what? How do people find and buy mobile
applications? In 2006 alone, roughly $2.5 billion dollars’ worth of games
were sold worldwide so let’s discuss how you can grab a piece of it.
There are currently two main ways to get your applications working
for you. The first way is to make a deal with a network operator or carrier
for a slot on their ‘deck’. The deck is a space on their mobile portal
where the top mobile applications (usually games) are made available for
21 For a great introduction to JSR-184, check out developers.sun.com/mobility/apis/
articles/3dgraphics.
22 www.jcp.org/en/jsr/detail?id=297
23 www.forum.nokia.com/main/resources/technologies/snap mobile
ROUTES TO MARKET 23
subscribers to download. The subscribers usually have some deal where
they can download a certain number of applications per month and it
simply gets added to their bill.
This is a really difficult path to tread. To start with, you need to be a
tough negotiator with a strong sales pitch and a business plan. Secondly,
operators tend to look for applications that are unique in some way so that
they will sell well, and there are already thousands of titles out there so a
mobile version of Frogger probably isn’t going to cut it. Thirdly, operators
tend to avoid making deals with small-timer ’unknown’ developers – not
only because of quality concerns but also because when something does
go wrong, it is the operator that must deal with the irate customer not the
developer. Lastly, in order to mitigate some of this risk, operators often
insist that MIDlets be Java Verified, which can introduce some additional
overhead that needs to be taken into consideration.
However, let’s say you ignore all of this and go ahead anyway. The
chances are pretty good that the last hurdle will tell you if your application
is truly ready. The Java Verified program24
is a quality assurance program
run by third-party testing houses that ensure MIDlets meet well-defined
and accepted sets of guidelines. MIDlets that are Java Verified can use
the Java Powered logo on their splash or ‘about’ screens which marks the
software as having passed a rigorous testing process. This conveys a level
of trust in the quality of the software that is widely regarded in industry.
A better way for small developers is to work with content aggregators,
companies such as www.gamemobile.co.uk, www.handango.com and
www.glu.com with online portals hosting thousands of mobile applica-
tions available for sale straight to the public. The details of the process
varies, but generally speaking, they host your software for free (or a very
small fee) and then take a cut of each sale.
There are distinct advantages to this. The content aggregators handle
marketing, billing, payments and invoicing; they are already well known,
have disaster recovery plans for their server farms and are likely to have
large volumes of Internet traffic which translates directly into increased
sales. They also tend to be far more interested in the application than in
the fact that you’re a small business.
Other areas that need thinking about include a support framework
for your application. This can involve taking support calls, responding
to FAQs or emails, forum administration, distributing patches, releasing
upgrades and, worst of all, processing refunds. We hope this won’t happen
too often and the best way to prevent it is to get hold of hardware and
test it thoroughly. For further information about taking your application
to market, we recommend ‘Getting to Market’, a booklet published by
Symbian Press, which can be downloaded from developer.symbian.com/
booklets.
24 www.javaverified.com
Other documents randomly have
different content
CHAPTER XXV
Homeward Bound—The Stowaway
Having cleared the English customs and with a clean bill of health,
we were ready to sail. The pilot was on board and his boat's crew
had a line fast through the stern chalk so that we could tow them
with us clear of the channel reef. Once clear of the reef all that
remained to do was to haul the pilot boat alongside and have this
servant of His Majesty climb down the Jacob's ladder and into the
boat which would bear him away to the spot where the sound of the
surf merged into the music of the clinking glass.
While giving orders to rig out slip lines for him I heard a familiar
voice on the wharf sing out "Bon voyage, bon voyage." I looked up
to see the portly figure of Captain Kane. He looked as if he had slept
in his clothes. His pea jacket had many wrinkles in the back and in
front it was inclined to roll up toward his chin. I jumped ashore to
say good-bye to this kind, if groggy old sea dog, shook him by the
hand, and thanked him for my trip to the interior of the island,
saying that I hoped to see him again.
"You know," he said, "I am getting old, but the smell of the
Stockholm tar, the white flowing sails, the squeaking blocks, the clink
of the capstan, bring back memories of long ago, and, damn it all, it
makes me young again."
Captain Kane laid great stress on the hurricane season, as January,
February and March were the months to be dreaded in the South
Seas. After seeing the boulder that had been hurled by the last
hurricane on these islands, I was hoping that I should be well
enough to the northward, so that if one should come I would be out
of the storm center, and therefore out of danger. The pilot was
nervously pacing up and down the main deck anxious to get me
away from the wharf and out to sea. Possibly a game of chess had
been left unfinished. I jumped aboard and ordered the foresail and
main jib set. With this done and the slip lines hauled aboard, the
"Wampa" glided away from the wharf as if propelled by steam.
With the aftersails spread and set to the southeast trades, and
sheets trimmed to the wind, we were not long in clearing the
channel reef and getting out into open water. After the pilot left I
ordered the topsails set. The breeze was fair, and I was anxious to
clear Bangor Island and get to the westward of it before darkness
set in.
The crew looked happy even after their night's debauch, some were
whistling, others humming familiar ditties. Riley could be heard
singing "Rolling Home Across the Sea" from his position on the
foretopmast, as he changed the topsail to windward, a job which is
usually done with very little sentiment of home or any other place.
Distance was shutting out the tall green palms around Suva, and the
town itself was just a speck on the horizon. Taking careful cross-
bearings of Bangor Island, so as to avoid the dangers and
submerged coral reefs that project from it, I ordered the staysails set
to increase our speed so that with darkness I would be well to the
westward.
Our staysails were put away and stowed in the fore peak when we
came into port. The second mate went forward to get them up, and
Swanson went down to bend a line around them before hauling
them on deck. He had been down in the fore peak only a minute
before he came up the ladder running very excitedly and saying that
there was a dead man lying on the staysails. The crew, much upset
by this remark, slunk away from the fore peak hatch as if deadly
fumes were coming from within, so I got a lantern and went down
to see the supposed dead man. I was confronted by a Hindoo
stowaway.
He was so weak from the heat of the fore peak and thirst that he
seemed to have little life left in him. I called up to the deck above
for a couple of men to come down and give me a hand to carry him.
Old Charlie and Riley cautiously felt their way down, Riley giving
orders to the crew above not to stand too close to the small hatch,
as it might be necessary for him to ascend with all possible speed
and he did not care to have any obstruction to his flight. Old Charlie
approached with his usual forebodings. The finding of the dead
Hindoo, in his estimation, meant nothing less than doom and
destruction to all on board.
Riley was more cheerful when he found that there was little chance
of physical danger from the supposed dead man. Bending the rope
around him and carrying him to the mouth of the hatch, I shouted to
the crew on deck to haul away very gently. We steered him up the
hatch and landed him on deck without any serious bumps. The cool
breeze restored him, and when we forced some water down his
throat he began to show signs of life.
I went aft to get a glass of Scotch whiskey, knowing that this would
stimulate the heart action. After taking a teaspoonful, his moaning
changed to some kind of Hindoo gibberish. This change seemed to
amuse the crew. They no longer looked gloomy and down in the
mouth, but seemed very willing to help him in his fight for life. As he
lay there I was seized with a very inhuman and selfish impulse. The
night shades of the tropical evening were becoming conspicuous in
the western horizon, the run on the log showed the "Wampa"
sixteen miles to the southward and westward of Suva harbor, with
the southeast point of Bangor Island bearing two points on the
starboard bow.
Should the Hindoo stowaway come back to life, it would be
necessary to tack ship and put back to Suva in order to put him
ashore.
U. S. alien laws are well known to sea-faring men. This stowaway
had no money, no position, and all that he had in the way of clothes
was a thin pair of pants. Should unfavorable conditions prevent my
putting him ashore, I would be forced to carry him to San Francisco.
Once there I knew what the immigration authorities would do to me
or to the owners. More than likely I should have to pay his passage
back by steamboat to the Fiji Islands. With darkness approaching it
was not my intention to put back to Suva and run the risk of striking
the reef at the entrance of the harbor. For these reasons, I should
much prefer a sea burial for the Hindoo stowaway.
While these hard and unsympathetic thoughts were passing before
the visible horizon of my mind, I was nevertheless attracted by his
delicate and artistic form. The long and straight black hair, the finely
molded ears, the aquiline nose, the perfect profile, the well-rounded
chin, the sensual mouth with its uniform white teeth were truly
oriental of high caste. An unusual type for a Fijian contract laborer.
I was deeply impressed with his boyish figure as he lay struggling for
breath on the deck. Suddenly I was seized with an impulse of
sympathy for this frail-looking creature. Grasping the bottle of Scotch
I pressed it to his lips and poured some down his throat. This act
caused him to strangle. After fighting for breath he opened his eyes
and sat up against the hatch combings.
His eyes were bright and fiery and seemed to penetrate through one
like an X-ray. They took in the situation at a glance. He realized that
he was out at sea. His gaze alternated from the flowing sail to the
members of the crew. His eye finally rested on Swanson, he being
the most brutish looking sailor of those who were standing around,
and therefore the most to be feared. I spoke to the Hindoo and said,
"How long have you been on board?"
"Oh," said he, "I have been down there," pointing to the fore peak,
"for three days." He spoke English without an accent. Then he told
how he had swam off to the ship, while we were still lying at anchor,
and said that he had no idea that we would have been delayed so
long before putting to sea.
I then told him that it would be impossible to carry him to the United
States of America. Although weak from heat and hunger, he
staggered to his feet and kissed my hand, crying, "Oh, please,
Captain, take me along with you. I cannot live there under these
horrible conditions, working for sixpence a day with nothing to eat
but curry and rice. I will work for you, I will do anything, only take
me away from here."
I deeply resented my previous thought of disposing of this intelligent
Hindoo. The picture this outcast made standing there trembling, with
tears streaming down his boyish face, pleading as though his heart
would break, was getting the best of me. Very few men of the sea
can stand tears and emotion. Although hardened by years of kicks
and knocks, the old-time sailor would much prefer a knock-down
and drag-out to any signs of agitation. Many of the crew themselves
consciously looked to windward and wiped away a rusty tear.
While the Hindoo was still pleading, Swanson stepped up to me and
between sobs said, "I wish you would take him along, sir, I have no
one in the world to care for, and I can easily spare the forty dollars
that you say will be necessary for him to enter the United States."
With this offer coming from a man like Swanson, I was as much
overcome as the Hindoo was, in his pleading for liberty to be taken
away from the low and dirty castes of Bombay and Calcutta which
furnish labor for the Fiji Islands. He thanked Swanson by gracefully
bowing and said, turning to me, "I am sure you can make some use
of me on your voyage home." This statement proved true, for had it
not been for the stowaway, this narrative would never have been
written.
The Socialist cook was standing with his back up against the galley,
deeply impressed with this new possibility. From the way he ran to
make milk toast for the Hindoo, one would think that at last he had
discovered a new clay to mold and construct and pattern after his
own impressions.
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
CHAPTER XXVI
The Mysterious Hindoo
With the Hindoo question solved and the fisherman's staysails set,
Suva was lost in the distance and remained but a memory. By the
time the studded diamonds in their azure setting were twinkling in
all the splendor of a Southern sky, we were well to the westward of
Bangor Island. We had nothing to fear from coral reefs until we
neared the Gilbert group, which lay east of the 180th meridian and
north and south of the Equator.
After the Hindoo had eaten the milk toast and found that he was in
the midst of friends, sailing away to a country where opportunity
knocks on the door of hovels, he no longer looked the slave to his
master. He refused to bunk in the forecastle, preferring to sleep
under the forecastle head. The tropical nights were warm, and for
the time being this was a comfortable part of the ship in which to
sleep. The crew were kind enough to furnish blankets for him, in
fact, were willing to give him anything they had, for they considered
him an unusual guest.
At ten o'clock I turned in and left orders with the second mate to call
me at midnight. By that time I knew that if we held our present rate
of eleven knots per hour, we should be far enough to the westward
to change the course, and haul her more northerly. Coming on deck
at eight bells and getting the distance run on the log, I went back to
my room to measure the distance on the chart before changing the
course. I decided to run one more hour before changing to the
northward.
Old Charlie was at the wheel, and it seemed from the way he was
clearing his throat that he was anxious for a chat. But discipline
forbade. I walked forward to look at the sails, and see if they needed
sweating up. While looking around I ran into Riley, who as usual was
smoking his clay pipe, with its black bowl and short stem. It was
strong enough of nicotine to drive a wharf-rat to suicide.
"Riley," said I, "no doubt you are happy that we are on the last leg
of our voyage."
Before answering he gave a few heavy puffs on the old dudeen to
insure its not going out. While he was doing this I immediately
changed for a new position to windward, for to be caught to leeward
of these deadly fumes was to share the fate of the wharf-rat.
"Well," said Riley, "I am, and I am not."
"Come," I replied, "what is it that troubles you?" Thinking that I had
found the source of his discontent, I added,—"Surely, you can't
expect me to feed you on Scotch whiskey all the passage home?
What little there is on board must be kept for medicine. Just think
what might have happened to the poor Hindoo had I not had a little
Scotch left on board."
At the mention of the Hindoo's name Riley stepped up close to me,
saying, "Whisht, and it is that what is troubling me, it is that damned
coolie," and he pointed to the forecastle.
"Surely," I protested, "you are not afraid of that poor weak
creature."
Riley fastened down the tin cover to his pipe so as to secure the
remains of the tobacco for future use. Economy of tobacco is strictly
observed on long voyages. Even the ashes have an intrinsic value
among sailors, like the kindling wood of a coal stove. Tucking the
pipe away in the folds of his breeches, he said:
"Ho, ho, and it is afraid you would have me! Shure'n I am afraid of
nothing in the say, and I will be damned if I will be afraid of
anything on top of it."
"Well, what about the Hindoo, what harm can he do to you?"
"Oh, it's the divil a bit he will be doing me. It's his snaky movements
and his ferret eyes that is getting on me nerves. During the dog-
watch," continued Riley, "we fixed a place under the foc's'le head for
the coolie, giving him what blankets we could spare. At eight o'clock
our watch below turned in. Says I to Dago Joe, 'Turn down the glim.'
'I will blow it out,' says he. 'Not by a damn sight,' says I. 'Shur'n we
are liable to scrape our bottom on an auld coral reef around here,
and it isn't Mike Riley that is going to get caught like a rat in a trap.'
The Dago is a reasonable man to talk to, and with that he turns the
light very low. About eleven o'clock I woke up along the hearing
Broken-Nosed Pete snoring. After throwing me auld shoe at him, I
rolled over with me face to the scuttle hatch, to get meself another
nap before eight bells, when I see the Hindoo standing there at the
bottom of the ladder. I rubbed me eye to make sure it wasn't
desayving me. Pulling meself together, I says to meself, says I,
'Whativer he is, he is there for no good purpose.' Begob, the
strangest thing about the coolie was that he did not move a muscle,
but stood there like a statue, staring straight into me eye.
"I shouted to the Dago to turn up the light, which is within easy
reach of him. Says I, 'Things are not as they should be down here.'
With me eye still on the Hindoo, Dago Joe turned up the light. I
declare to me Maker when the light was turned up the Hindoo had
disappeared.
"'That's damned strange,' says I to Dago Joe. 'Be Hivens he was
standing there not a minute ago,' and when I comes up on deck at
eight bells I looked under the foc's'le head and there he is, fast
asleep. So I lights me poipe, and takes a look over the sea to
leeward of the foresail, to see if we are still in sight of land. While I
am standing there humming a bit av an auld ditty, all of a sudden I
felt meself in the presence of something uncanny, and turning
around quick-like, there stood the coolie. Ses I to him, ses I:
"'What are you up to, me boy?'
"'Oh,' says the coolie, 'the wash on the prow is disturbing to my
peaceful slumbers. I should much prefer being crooned to sleep by
the waving branches of a Himalayan evergreen.'
"Ses I, 'Me coolie friend, no more of your palavering. Back to bed
with you, and stay there.' I looked at him again, and, shure, Howly
St. Patrick, he disappears like he did in the foc's'le."
"Where is he now, Riley?"
"Begobs, and I don't know, sir."
I went forward to see the strange visitor who seemed to be causing
Riley so much misery. There, under the forecastle head, the Hindoo
lay, wrapped in his blankets, sound asleep.
"Riley," said I, "you drank too much Scotch last night; be careful that
you don't get the Jimmies and jump overboard. If you feel yourself
slipping just tie a gasket around you. We need you to work ship on
the voyage home."
These insults were too much for Riley. He slunk away to the lookout
where Broken-Nosed Pete would lend a willing ear to his story of the
Hindoo and his abuse of me.
At one o'clock, feeling sure of the reefs, I changed the course to N.
N. W.
The next morning the Hindoo was eating his breakfast off the
forehatch and looking much better than he had on the preceding
evening. He rose and thanked me kindly for the interest we had
taken in him, saying:
"I feel the pleasure of liberty after my prison term, among those
terrible people. As for last night, I was quite comfortable. I can
easily adapt myself to the new environment. But although I could
not quite understand what the one-eyed man meant when he bent
over me in the night, exclaiming, 'There he is, and the divil a move
out of him,' I feel nevertheless, that I am in the midst of friends, and
I shall do my best to entertain their friendship."
These quaint expressions were pleasing to me, and I continued the
conversation. He said that he had had no sea experience. That while
going from Bombay to the Fiji Islands he was battened down in the
hold with the rest of the coolie labor, and only allowed to walk the
deck a short time in the evenings. He was anxious to work and help
in any way that he could. The second mate put him to work
scrubbing paint-work. There is always plenty of this kind of work to
be done on every ship. The Hindoo went to work with a will, as if
glad to have the opportunity.
For the next four days the southeast trades held fair, until we were
well to the northward of the Fiji group. I was hoping to get east of
the 180th meridian before crossing the Equator, This would give me
a better slant before I struck the northeast trades. Then in latitude
about 30° north we would encounter the westerly winds, which
would be fair for the Pacific coast.
I was well pleased with the progress we had made since we left
Suva, and I anticipated making a sailing record from the Fijis to San
Francisco.
Events had favored us since our departure. The crew were willing
and the good ship herself seemed to feel that she was homeward
bound. But our outward peace was somewhat broken by the sudden
and mysterious illness of the Hindoo, who, after the second day out
from Suva refused to eat, complaining of a headache, and later
remaining for hours in what appeared to be almost a state of coma.
I was worried by this new disease, and hoped that it would not
prove to be contagious. As a precautionary measure, I removed the
Hindoo aft to the deceased Captain's cabin. For two days it was with
a great effort that he was even aroused to drink a cup of bouillon.
Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun
CHAPTER XXVII
The Hurricane
At two o'clock in the morning of our fifth day from Suva, I was
awakened by hearing the booms and gaffs swinging as if in a calm. I
thought this very strange, as the southeast trades should have held
until we were well across the Equator. Rushing up on deck, I was
indeed surprised to find the sails hanging in midships, and not a
breath from any quarter of the compass.
I ordered the staysails down and the topsails clewed up and made
fast, also the flying-jib and outer jib. (These lighter sails in a calm
usually flop to pieces, especially where there is a rolling swell.) Away
to the eastward I noticed a heavy bank of clouds, but considered
this of minor importance, as we were nearing the Equator. It usually
means heavy rain, but seldom wind.
Yet this morning there was something out of the ordinary, because
of the long swell coming from the northeast, and the sickly and
suffocating atmosphere. The unusual stillness was intensified by the
murmuring and talking of the crew. The men who were making fast
the headsails on the flying jibboom could be heard plainly from the
poop deck, growling and swearing as they passed the gaskets
around the sails. Such was the funereal quietness of the morning
that even the stars were hidden in halos of a yellowish color.
Giving instructions to haul in the log line, I went below to look at the
barometer. I was surprised to find it falling. I next consulted a Pacific
directory, and found that these unusual conditions preceded a
hurricane. This information upset me greatly. I had never
experienced a hurricane, but well knew that their force and
destructive power was very great.
Before going on deck again, I looked in on the Hindoo in the
Captain's room. As usual, he was in a stupor, and looked as if he had
not moved since being fed the preceding evening. I did notice from
the heaving of the skeleton-like breast, that the breathing was
regular, and not intermittent as it had been on the preceding
evening.
On deck, I had all the reef-earrings brought up from the lazarette,
and got everything in readiness for any emergency.
I was well to the westward of the Gilbert group, but still to the
eastward of the 180th Meridian. Should the hurricane come out of
the east, I could heave to and ride it out without any danger of
fetching up on one of the Gilbert Islands.
In the cabin the barometer was falling so fast that it now showed
hurricane weather. I knew that it was only a question of a few hours
before we should feel its fury. My experience was limited in the laws
of storms. If we were in the storm center it would be necessary to
put her into the port tack. By doing this I should be forced south,
and back onto the northern isles of the Fiji group, while on a
starboard tack I should be driven onto a lee shore of the Gilbert
Islands. Either course meant destruction.
With daylight and hot coffee this gloomy situation assumed a more
cheerful aspect. While the old sailor has the light of day to guide him
over storm-tossed decks, he becomes more tolerant of ship and
crew.
At half-past five the white caps could be seen coming from the
northeast, and before we got the spanker down the gale struck us,
about six points on the starboard bow. The old ship reeled to
leeward, with the lee rail under water. The decks were almost
perpendicular. It seemed that no power on earth could right her to
an even keel again. There were two men at the wheel, trying to
keep her off before the gale, but it was of no avail, for she refused
to answer her helm, and lay throbbing as if undecided whether to
seek a watery grave, or to continue her fight for victory.
Swanson, by a heroic effort, cut the fore and main sheet, and then
let go by the run. The tense situation was relieved as the booms
flew seaward over the lee rail. We then kept her off before the gale
with the wind on the starboard quarter, immediately setting to work
to reef the fore and main sail.
By nine o'clock, three hours and a half later, it was no longer a gale,
but a hurricane. With three reefs in the foresail and a goose-wing
spanker, we ran before it. It was too late to heave to. With such a
tremendous sea running it would mean destruction to ship and crew
to try the latter move. As it was, the ship was awash fore and aft
from seas breaking over her. Should the hurricane hold out for ten or
twelve hours more with our present rate of speed we should be
dashed to pieces against one of the Gilbert group.
At four bells the velocity of the hurricane was so great that one was
in danger of being blown off the schooner. We rigged life-lines on
the fore and main decks, also on the poop deck, and by their help
the crew managed to keep from being washed or blown overboard.
The sea looked like an immense waterfall, one enormous roaring
mass of foam. Occasionally from out of this terrible cataract a
Himalayan sea would gain in momentum and dash itself against our
starboard quarter, submerging the vessel. At such times all that
would be identifiable of the "Wampa" would be her rocking spiral
masts.
Like a struggling giant she would raise her noble head and shake
herself clear of this octopus, shivering, but never spent.
About noon the hurricane jumped suddenly from the northeast to
east southeast, without losing any of its velocity. In order to keep
running before it, and keep the wind on our starboard quarter we
hauled more to the northward and westward, although to do this it
was necessary to drive into a beam sea, which made it all the more
dangerous. Also the sea was driving from the east southeast and
this formed a cross sea.
When these two seas came together, the "Wampa" would rise and
poise on them as if on a pivot. In this position, and with the gale
blowing on the starboard quarter, her head would be thrown into the
beam sea. It looked as if we could not survive. There was constant
danger of our being broken up into small pieces. We dropped the
peak of the spanker that formed the goose-wing sail, put it into
gaskets, and ran with a three-reefed foresail.
We then put the oil-bags over the stern in the hope of quieting these
angry seas. But this was useless. While we were fastening the lines
that held the oil-bags in the water, a crushing comber came whistling
along and filled our stanch little ship again from stem to stern. When
she shook herself clear of the boiling foam I noticed that our oil-
bags were gone, and with them the Captain's boat which hung from
davits over the stern.
Old Charlie and Dago Joe were steering. Old Charlie had a faraway
look in his watery eyes as he spoke and said:
"I am afraid, sir, this will be my last trick at this wheel."
I spoke harshly to this old sailor, saying, "To Hell with sentiment, this
is no place for it. Watch your steering and don't feel sorry for
yourself." Had I known what was so soon to happen I should not
have so upbraided this poor harmless old soul. I have often
regretted it.
Riley, who was taking no chances, was seemingly not all
handicapped by his one eye. Always alert and as agile as a tiger, he
went about the decks as if nothing were out of the ordinary,
although to hear him talking to himself one would think that he
expected to be extinguished by every sea that came. He had about
twenty feet of manila rope tied about his waist with the end held in
his hand. When a sea would hit us Riley would see it coming, and
would pass the rope end around a belaying-pin or anything that he
thought would hold his weight.
It was while she cleared herself from the sea that carried away the
Captain's boat that I found Riley twisted around the spanker sheet
like an eel. It took him some time to extricate himself, always
watching the progress of the stern sea, and not seeming to notice
his number ten brogans, which had woven themselves into the
spanker-sheet falls. The hurricane was raising havoc with Riley's
mustache. Having blown all over his face, it looked as if the only way
to quiet it would be to put it into a plaster of Paris cast. He finally
pulled himself clear of the sheet, exclaiming:
"Be Hivins, and wasn't that a close call—"
Just then Swanson came running aft and reported that the
martingale guy had carried away on the flying-jibboom. It was then
that my heart sank within me. I knew what to expect. Dismantled,—
then to perish at sea!
CHAPTER XXVIII
The Master Returns
The thought of our dead captain came to me, of what his will would
have been in this crisis of life and death, and I paused to wonder
why he had not rested until he was assured that I would not carry
his precious treasures back with me. Did he expect this situation,
and doubt my ability to cope with it? Action followed thought, and I
ordered the second mate and the crew forward to see what could be
done with the martingale guy.
Still the humor of the moment appealed to me. As Riley left the
poop he shouted, "Be the Holy St. Patrick, it has blown the buttons
off me oilskin coat." There was no question about its blowing, but it
was also possible that his snakelike position on the spanker-sheet
had something to do with the lost buttons.
It was now past noon. None of the crew cared to eat, preferring the
wave-swept deck to anything the cook had to offer. The murderer
who pays for his crime on the gallows and enjoys his ham and eggs
on the morn of execution may be happy indeed, but this does not
apply to the sailor. When there is a life and death battle on with the
elements, he is there to grab the one last chance if there be one. If
not, he prefers a watery grave to claim him with his stomach empty.
The seas kept coming larger, and every time one would break and
spend itself on the decks I thought it would be the last, and that she
could not arise. But she shook herself clear as she climbed the
waves; then again the sea, and again the dread.
I could not leave the poop nor the two men at the wheel. A wrong
turn at this howling, raging time, would mean quick despatch to the
land of no awakening. Sometimes even the helmsmen grew afraid,
but a word of encouragement sufficed to quiet them.
While I was standing to windward of the men at the wheel, watching
her every move as she was pitched hither and thither on this crazy
spiral sea, she shipped a green sea that shook her from stem to
stern. It was with great difficulty that she raised her black hull to the
raging storm again. I shouted to the men at the wheel. It was too
late. She had broached to with the stern sea on the beam, and the
beam sea right ahead.
Then the beam sea submerged her, and by it I was carried across
the poop deck, and found myself held under the wheel-box, with
both legs pinned in a vise-like grip by the tiller, which extended
forward of the rudder-head. Although dazed and strangled by the
terrible impact of the water, I managed to twist the upper part of my
body towards the wheel and to murmur, "For God's sake keep her
off."
My weakened voice was lost in the tempest. There were no ears to
hear my pleadings. The men at the wheel were gone. Gone, indeed,
to a watery grave, and perhaps the others also. With me it would
not take long. Just another raking like the last one, and then the
finish. Again the cook's words echoed louder than the raging storm,
"Do we finish here?"
As I lay there pinned to the deck, too helpless to even call aloud,
and as it seemed waiting, waiting, for the executioner to spring the
deadly trap, I was conscious that the door of the companion-way
had closed with a bang so terrific that it sounded above the storm. I
twisted my head and shoulders around to see if I dared to hope.
There before me stood the Hindoo stowaway. He did not notice me
lying there pinned under the wheel-box, nor could I manage to
attract his attention.
With opal eyes glowing green and fiery red, he sprang to the wheel,
and with magnificent strength pulled on the spokes till they
screeched louder than the storm as they were dislodged from their
oxidized fittings. Harder and harder he pulled on the wheel. He
didn't even notice the seas breaking over him. The mysterious thing
about him was that he seemed to know what he was doing. He was
keeping her off before it.
In doing this he removed the tiller from my legs. At last I was free.
As I struggled and crawled to the weather-rail for support, the
Hindoo shouted in clear and ringing tones, in true seamanlike
fashion, looking neither to the right nor left, but straight ahead, as if
staring into a land-locked harbor. He repeated his order for the
second time in a high tenor voice:
"Get an axe out of the donkey-room and cut away the lee martingale
guy. Your flying-jibboom is gone overboard and is still held by the lee
guy. It is plowing a hole in the port bow."
I knew but one law. The law of self-preservation. My arms were
locked tight around the stanchion that supported the weather-rail.
That quick command of the Hindoo brought me sharply to the
realization that I was not yet given that quick despatch to the land
of nowhere, but was still in the flesh, and very much alive. My first
rational thought was, "What in Hell is the Hindoo doing at the
wheel?" My pride as a sailor resented the affront put upon my ability
as a sailor by a stowaway who was daring to assume the command
of my ship, and daring to issue orders to me.
Letting go my hold on the stanchion, I cautiously made for the
Hindoo helmsman. While in the act, she shipped another drencher. I
was carried off my feet and washed away to the lee scuppers. But I
managed, by some interposition of Divine Providence, to fasten my
arms around the mooring-bitt, thus saving myself from an angry and
cruel sea, which seemed to delight in playing with me as a cat does
with a mouse, only to swallow me up in its fathomless depths.
Once again she wrenched herself free of the mad swirl and her stern
went down until we were in a valley between mountains of water. I
realized as I looked up at the bows which seemed to be towering
above me, that the flying-jibboom, like a clipped wing, was missing.
Like a flash I wondered how the Hindoo knew that the jibboom was
gone.
As her stern ascended high into the air, I jumped for the wheel and
with an exclamation of joy I shouted, "God in Heaven, the Captain!"
There he stood beside the Hindoo. The dead Captain. The same
heavy mustache covered the lower lip. The same fiery eyes that
knew no defeat. He was looking straight ahead with muscle-set
jaws. He appeared as if in the flesh and ready as of yore to battle
with the elements.
Then, like a flash, he vanished, and the Hindoo stood alone, pulling
and tugging on the wheel with his supple arms.
He spoke, and his usually high-pitched tenor voice rang out
piercingly clear. "Cut away your jibboom, you have no time to lose.
Have no fear."
I knew that her former Captain was in command of the ship, and
that his masterly seamanship wrought through the Hindoo. I crept
forward with new courage to do his bidding.
Huddled together beneath the forecastle-head stood what remained
of the crew, who seemed not to know that two of their number were
gone. The second mate was praying, and helpless from fear to be of
any use in handling the schooner. Riley had his three-inch sailor's
rope fast to the windlass with one extra turn around his body. He
was taking no chances. Swanson was the only one without fear.
When I called for a volunteer to cut away the flying jibboom he
made for the axe and rushed onto the sea-swept forecastle-head. As
the schooner arose high in the air, he swung over the lee bow and
with one stroke of the axe cut away the hemp lanyard that was
holding the massive spar from its freedom.
Welcome to our website – 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

More Related Content

PDF
Programming Mobile Devices An Introduction for Practitioners 1st Edition Tomm...
PDF
Symbian OS C for Mobile Phones Volume 3 1st Edition Richard Harrison (Editor)
PDF
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
PDF
Programming Mobile Devices An Introduction For Practitioners Tommi Mikkonen
PDF
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
PDF
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
PPTX
Mobile operating system..
PDF
Symbian Os Communications Programming 2nd Ed Iain Campbell Dale Self
Programming Mobile Devices An Introduction for Practitioners 1st Edition Tomm...
Symbian OS C for Mobile Phones Volume 3 1st Edition Richard Harrison (Editor)
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
Programming Mobile Devices An Introduction For Practitioners Tommi Mikkonen
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
Symbian OS Communications Programming 2nd ed Edition Iain Campbell
Mobile operating system..
Symbian Os Communications Programming 2nd Ed Iain Campbell Dale Self

Similar to Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun (20)

PDF
Intro to Java ME and Asha Platform
PDF
Mobile Application Development
PDF
B feigin mobileapplicationdevelopment
PDF
Java me introduction
PDF
Java me introduction
PDF
Java me introduction
PDF
Beginning Java Me Platform 1st Edition Ray Rischpater
PDF
Developers Guide To The Galaxy 8th edition
PPT
Mobile Software Development
PDF
Mobile Developer's Guide To The Galaxy Vol.7
PPTX
MOBILE OPERATING SYSTEM
PDF
Mobile Developer's Guide To The Galaxy Edition 2
PDF
Mobile Pres
PPTX
J2ME mobile app development
PDF
Mobile Developers Guide To The Galaxy Vol.6
PPTX
Java ME - 01 - Overview
PDF
Mobile Developer's Guide To The Galaxy, 5th edition
PPT
Modern mobile development overview
PDF
Java ME - Introduction
PPT
01 Symbianosbasics Introducao
Intro to Java ME and Asha Platform
Mobile Application Development
B feigin mobileapplicationdevelopment
Java me introduction
Java me introduction
Java me introduction
Beginning Java Me Platform 1st Edition Ray Rischpater
Developers Guide To The Galaxy 8th edition
Mobile Software Development
Mobile Developer's Guide To The Galaxy Vol.7
MOBILE OPERATING SYSTEM
Mobile Developer's Guide To The Galaxy Edition 2
Mobile Pres
J2ME mobile app development
Mobile Developers Guide To The Galaxy Vol.6
Java ME - 01 - Overview
Mobile Developer's Guide To The Galaxy, 5th edition
Modern mobile development overview
Java ME - Introduction
01 Symbianosbasics Introducao
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Basic Mud Logging Guide for educational purpose
PDF
Computing-Curriculum for Schools in Ghana
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PPTX
Lesson notes of climatology university.
PDF
01-Introduction-to-Information-Management.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Types and Its function , kingdom of life
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Cell Structure & Organelles in detailed.
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
human mycosis Human fungal infections are called human mycosis..pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Classroom Observation Tools for Teachers
Module 4: Burden of Disease Tutorial Slides S2 2025
Basic Mud Logging Guide for educational purpose
Computing-Curriculum for Schools in Ghana
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPH.pptx obstetrics and gynecology in nursing
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Lesson notes of climatology university.
01-Introduction-to-Information-Management.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Types and Its function , kingdom of life
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Cell Structure & Organelles in detailed.
O5-L3 Freight Transport Ops (International) V1.pdf
Ad

Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun

  • 1. Mobile Java Development On Symbian Os Java Me And Doja For Smartphones Roy Ben Hayun download https://ebookbell.com/product/mobile-java-development-on-symbian- os-java-me-and-doja-for-smartphones-roy-ben-hayun-1078948 Explore and download more ebooks at ebookbell.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. Learn Java For Android Development Migrating Java Se Programming Skills To Mobile Development 4th Edition Peter Spth https://ebookbell.com/product/learn-java-for-android-development- migrating-java-se-programming-skills-to-mobile-development-4th- edition-peter-spth-11231716 Java 16 Mobile Phones And Android Software Development No Isbn Poul Klausen https://ebookbell.com/product/java-16-mobile-phones-and-android- software-development-no-isbn-poul-klausen-47502948 Android For Absolute Beginners Getting Started With Mobile Apps Development Using The Android Java Sdk 1st Edition Grant Allen https://ebookbell.com/product/android-for-absolute-beginners-getting- started-with-mobile-apps-development-using-the-android-java-sdk-1st- edition-grant-allen-31485194 The Definitive Guide To Modern Java Clients With Javafx Crossplatform Mobile And Cloud Development 1st Edition Stephen Chin https://ebookbell.com/product/the-definitive-guide-to-modern-java- clients-with-javafx-crossplatform-mobile-and-cloud-development-1st- edition-stephen-chin-10571836
  • 3. Android For Absolute Beginners Getting Started With Mobile Apps Development Using The Android Java Sdk Grant Allen https://ebookbell.com/product/android-for-absolute-beginners-getting- started-with-mobile-apps-development-using-the-android-java-sdk-grant- allen-169380788 Comprehensive Java Programming Course Mastering Syntax Objectoriented Concepts And Mobile Applications Development Taylor https://ebookbell.com/product/comprehensive-java-programming-course- mastering-syntax-objectoriented-concepts-and-mobile-applications- development-taylor-56835408 Enterprise J2me Developing Mobile Java Applications 8th Print Yuan https://ebookbell.com/product/enterprise-j2me-developing-mobile-java- applications-8th-print-yuan-22042722 Enterprise J2me Developing Mobile Java Applications https://ebookbell.com/product/enterprise-j2me-developing-mobile-java- applications-1276916 Building Mobile Applications With Java Joshua Marinacci https://ebookbell.com/product/building-mobile-applications-with-java- joshua-marinacci-4098266
  • 6. Java ME on Symbian OS Roy Ben Hayun With Sam Mason, Daniel Rocha, and Ivan Litovski, assisted by Sam Cartwright Reviewed by Gavin Arrowsmith, Brendan Donegan, Erik Jacobson, Martin de Jode, Mark Shackman, Jo Stichbury Head of Symbian Press Freddie Gjertsen Managing Editor Satu McNabb A John Wiley and Sons, Ltd., Publication
  • 8. Java ME on Symbian OS Inside the Smartphone Model
  • 10. Java ME on Symbian OS Roy Ben Hayun With Sam Mason, Daniel Rocha, and Ivan Litovski, assisted by Sam Cartwright Reviewed by Gavin Arrowsmith, Brendan Donegan, Erik Jacobson, Martin de Jode, Mark Shackman, Jo Stichbury Head of Symbian Press Freddie Gjertsen Managing Editor Satu McNabb A John Wiley and Sons, Ltd., Publication
  • 11. Copyright  2009 John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England Telephone (+44) 1243 779777 Email (for orders and customer service enquiries): cs-books@wiley.com Visit our Home Page on www.wiley.com All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd, Saffron House, 6–10 Kirby Street, London EC1N 8TS, UK, without the permission in writing of the Publisher. Requests to the Publisher should be addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England, or emailed to permreq@wiley.com, or faxed to (+44) 1243 770620. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The Publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold on the understanding that the Publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. Other Wiley Editorial Offices John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809 John Wiley & Sons Canada Ltd, 6045 Freemont Blvd, Mississauga, Ontario, L5R 4J3, Canada Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Cataloging-in-Publication Data Hayun, Roy Ben. Java ME on Symbian OS : inside the smartphone model / Roy Ben Hayun, with Sam Mason ... [et al.]. p. cm. Includes bibliographical references and index. ISBN 978-0-470-74318-8 (pbk. : alk. paper) 1. Smartphones–Programming. 2. Java (Computer program language) 3. Symbian OS (Computer file) I. Title. TK6570.M6H33 2009 005.26’8–dc22 2008053889 British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library ISBN 978-0-47074318-8 Typeset in 10/12 Optima by Laserwords Private Limited, Chennai, India Printed and bound in Great Britain by Bell & Bain, Glasgow This book is printed on acid-free paper responsibly manufactured from sustainable forestry in which at least two trees are planted for each one used for paper production.
  • 12. Contents Foreword ix Kicking Butt with Java Technology on Symbian OS xv About This Book xvii Author Biographies xix Author’s Acknowledgements xxi Symbian Press Acknowledgements xxiii Part One: Introduction to Java ME and Programming Fundamentals 1 1 Introduction to Java ME, Symbian OS and Smartphones 3 1.1 2003: Rise of the Mobile 3 1.2 2008: Mobile Generation 6 1.3 Meet the Host – Symbian OS 7 1.4 What Is Java? 9 1.5 Java ME 12 1.6 Why Use Java ME on Symbian OS? 17 1.7 Java’s Place in the Sun 21 1.8 Routes to Market 22
  • 13. vi CONTENTS 1.9 Time for a Facelift 24 1.10 Back to the Future: MSA 2.0 and MIDP 3.0 24 1.11 Summary 26 2 Fundamentals of Java ME MIDP Programming 27 2.1 Introduction to MIDP 27 2.2 Using MIDlets 28 2.3 MIDP Graphical User Interfaces API 34 2.4 Non-GUI APIs in MIDP 56 2.5 MIDP Security Model 59 2.6 Networking and General Connection Framework 69 2.7 Using the Push Registry 78 2.8 MIDP and the JTWI 81 2.9 Mobile Media API 82 2.10 Wireless Messaging API 95 2.11 Symbian OS Java ME Certification 100 2.12 Summary 101 Part Two: Java ME on Symbian OS 103 3 Enter Java ME on Symbian OS 105 3.1 Running a MIDlet on a Symbian Smartphone 106 3.2 Which APIs Are Supported? 113 3.3 Proprietary JAD Attributes 122 3.4 Computing Capabilities of Java ME on Symbian OS 123 3.5 Java ME: Exposing the Power of Symbian OS 125 3.6 Tools for Java ME on Symbian OS 131 3.7 Java ME Management on Devices 131 3.8 Crossing to the Native Land of Symbian OS 139 3.9 Finding More Information 145 3.10 Summary 146 4 Handling Diversity 149 4.1 General Approaches to Handling Diversity 150 4.2 Detecting Diversity using Properties 151 4.3 Using Adaptive Code and Flexible Design to Handle Diversity 153 4.4 Handling JSR Fragmentation 158 4.5 Handling Transitions Between Foreground and Background 161 4.6 Supporting Diverse Input Mechanisms 162 4.7 Handling Diverse Multimedia Formats and Protocols 166 4.8 Handling Screen and Display Diversity 169
  • 14. CONTENTS vii 4.9 A Last Resort: NetBeans Preprocessing 173 4.10 Summary 173 5 Java ME SDKs for Symbian OS 175 5.1 Recommended Tooling Approach for Java ME on Symbian OS 176 5.2 Generic SDKs: Java ME SDK 3.0 and WTK 2.5.2 177 5.3 SDKs for the S60 3rd Edition and 5th Edition Platforms 178 5.4 SDKs for the UIQ 3 UI Platform 189 5.5 Summary 205 Part Three: MSA, DoJa and MIDP Game Development 207 6 Designing Advanced Applications with MSA 209 6.1 What Is MSA? 209 6.2 What Can I Do with MSA? 213 6.3 Spicing up Legacy MIDP Applications 222 6.4 Beyond MSA 1.1: MIDP 3.0 and MSA 2.0 227 6.5 MSA and Symbian OS 229 6.6 Summary 230 7 DoJa (Java for FOMA) 231 7.1 In the Beginning. . . 231 7.2 DoJa – the Basics 234 7.3 I Love JAM 238 7.4 DoJa Basic Operations Manual 240 7.5 Eclipsing DoJa 240 7.6 Dirty Hands 243 7.7 A Safe Port 250 7.8 DoJa 5.1 Profile 254 7.9 Summary 264 8 Writing MIDP Games 265 8.1 What Is a Game? 266 8.2 Building a Simple MIDP Game 273 8.3 MIDP 2.0 Game API Core Concepts 279 8.4 Building an Advanced Java Game on Symbian OS 282 8.5 Summary 303
  • 15. viii CONTENTS 9 Java ME Best Practices 305 9.1 Investing in the User Experience 305 9.2 Good Programming Practices 308 9.3 Streamlining the Deployment and Execution Lifecycle 322 9.4 General Tips for Symbian OS 325 9.5 Summary 327 Part Four: Under the Hood of Java ME 329 10 Java ME Subsystem Architecture 331 10.1 Java Applications and Symbian OS 331 10.2 Application Management Software 336 10.3 MIDP Push 337 10.4 Mean and Lean Virtual Machine 338 10.5 MIDP Implementation Layer 342 10.6 Handling Asynchronous Symbian OS Operations 346 10.7 Java-level Debugging Support 348 10.8 Performance 349 10.9 Security 350 10.10 Summary 351 11 Integration of Java ME and Native APIs 353 11.1 Importance of Integration with Symbian OS Services 354 11.2 Types and Levels of Integration 356 11.3 Integration Challenges, Costs and Considerations 357 11.4 Determining the Right Integration Style 358 11.5 Examples of JSR Integration 359 11.6 Summary 384 Appendix A: WidSets 385 Appendix B: SNAP Mobile 411 References 433 Index 435
  • 16. Foreword James Coplien It was great re-discovering through this book just how much of a nerd I am. Roy’s descriptions and exercises painted amazing pictures in my head of the internal workings of my own Nokia S60 phone, to the extent that I unearthed new and useful menus previously invisible to me. While I can’t promise that every casual reader will find this book suitable as a user’s guide, and while I can’t promise that every programmer will become an expert user of their own handset by reading the chapters that follow, I can promise the intent programmer a treasure chest of knowledge not only for understanding what goes on inside your phone but also for changing what goes on inside your phone. Java ME on Symbian OS is a title that sounds like nerd’s heaven – and it is (though it’s more than that, as I’ll come back to below). Though the title bears two trade names, the meat of the book proudly displays its inclusiveness across the market: Sun, Symbian, Nokia, Samsung, LG, Sony-Ericsson, Motorola . . . It’s the ultimate mash-up. This is a book less about niche technologies than about a broad phenomenon. It isn’t only a technological phenomenon but a sociological one; if you don’t view it that way today, I believe that vision is rapidly approaching tomorrow. To the everyday programmer, I think this book will open a new world of wonder, as history has similarly favored our industry several times in the past. Twenty years ago, someone would have thought you to be drunk if you asked him to take a picture of you with his phone. Today we have lost touch with photographic film and, to a large degree, with those ancillary devices called cameras. We used to have a shelf-full of gadgets for voice dictation on the run, digital photography, calendar management, and, yes, even communication – all of which are
  • 17. x FOREWORD converging on single small, convenient computers that are the brain- grand-grand-grand-grand-children of Alexander Graham Bell. And those boxes need software – software such as you will find in this book, along with guidance for bringing it to life. It was inevitable that the evolution of consumer programming should turn to the telephone. I remember the visions of unification of computers and telephones in the minds of people such as Jerry Johnson back in Bell Lab in the 1970s. We can now look back at the past 20 years and conclude that computers’ primary contribution to society has been not as calculating engines in their own right, but as tiny points on an almost fully-connected network that ties together most computers in the world. The phone network is more than just a metaphor for the worldwide web: it is often its backbone. As the pundits predicted, the intelligence has evolved out of the network into its periphery, out of its bowels and into its eyes, ears, and fingers. The intelligence hasn’t stopped at phones. Next year, Nokia and RWE are expected to market a box that extends the phone network to control heating, window shades, and home security cameras. The possibilities are endless. Programmable phones will replace not only cameras and small dictation machines, but will reach ever further into both our immediate and physically remote realities. They have already made a significant foray into the video game space, taking advantage of advancing display technology, complementing our newfound connections with reality with newfound escapes into fantasy. In the not so distant future, these two worlds may blend and merge. Whereas yesterday’s play was a personal Tamagotchi and today’s play includes multiple Tamagotchis talking via an infrared Tamacom protocol, tomorrow will see our phones as a Tamagotchi interface whereby we feed or clean up after the flesh-and- blood Fido back home – all with a sequence of a few DTMF tones. Roy’s book takes us on a journey into a land that is more than just nerd heaven. The history of computing has drawn more and more everyday folk into programming. This trend sits squarely in the center of the vision of people such as Alan Kay and Adele Goldberg: that computers should be the sidekicks of human beings from early life, enabling children of all ages to extend their memory and processing power by manufactured, rather than biological, means. This vision of a Dynabook – a truly personal computer, an extension of self – includes information tethered to the outside world as one of its central building blocks. Because my Dynabook is part of me, I get to program it. Today, that programming means setting a date on my calendar or setting an alarm for a meeting. Those humble acts may not entail using Java, but
  • 18. FOREWORD xi it’s still programming: as Dan Barstow used to say, ”No matter how high-level, it’s still programming.” To me, as a C++ programmer, Java looks almost like a scripting language. And that’s not even an insult. Java has perhaps finally realized its vision of ubiquitous expression of general-purpose computation that is portable and intelligible enough that Everyperson can at least tweak the code. I know that such æsthetics are difficult to judge from the seat of a professional programmer, but we can at least say that Java code provides a glimpse of such a world. Perhaps even my neighbor, the real-estate salesman, could read some of the code in this book and understand it well enough to play with it. Or my dentist. Or my banker. None of them are professional programmers. But each has a computer on his or her desk: a machine which 40 years ago would have terrified most secretaries, and which still terrifies some executives today. Machine creatures inhabit more and more of the human ecosystem. It’s interesting to note that such programmability has played out not in desktop phones (yes, they still exist) but in hand-held portable phones. Why? Perhaps it is because only personal cellular phones are close enough to our heart – or some other part of our anatomy – to truly be part of Self. It was a revolution when people who bought the early Ataris and Amigas discovered that they could actually program them themselves. We are perhaps on the threshold of a revolution that unleashes more powerful programming into the hands of what will be over one billion owners of Symbian OS phones in two or three years. Even if great programmers arise from only one in a million of these users of small-handheld computers that take pictures, play games, and even place phone calls, it will be enough to move the world. This book, as a nerd’s text, is nonetheless a bold foray into Dynabook territory. If nothing else, it will make you realize that if you own a regular personal computer and a mobile phone, that it’s within your reach – today – to write software that can be an at-hand extension of yourself any time, anywhere. It is perhaps one small step on the road to a future vision of even further integration between man and machine. Such integration must go forward with intense ethical scrutiny and social care; if we choose such a path, machines can make us even more human, humane, and social than we are today. I leave you with a poem which, when published, was wrongly attributed to me alone. It was written by the attendees at VikingPLoP 2004 as we took the human–computer symbiosis to its limit. Think of Java ME on Symbian OS as an important step on this journey. Nerds, children of all ages, and everybody out there: Happy Programming!
  • 19. xii FOREWORD Comfortable as blue jeans She fits. Part of me, yet not me; Unplugged: oxygen is her food And the breeze her power adaptor. Her identity mine, yet not me: I put her down, I take her up like a well-worn wallet plump with life’s means and memories. A thin mask worn in life’s play And both of us are players. I call her Self; she does not call me User A curse unique to programmers and other pushers. I and my computer are one But we own each other not. Envision this: my new machine, a soulmate, With whom I talk in whispers unencumbered by flesh and bone Software begotten, not made Of one being with its person. She hears my voice, and perhaps my thoughts rather than the drumming of my fingers that burdened her forebears: 35 calcium levers linking brain to digits, slow and tired machines of the information age. Now, mind to mind, there for tea and sympathy all day, and our night minds together process the day, sharing dreams – yet She slumbers not, nor sleeps. An invisible mask the birthright of all humanity; Her software penned by My soul And like my soul, her hardware Im-mortal, invisible Us together wise. Transparent personæ mine, yet not me, That with me loves, and lives, and walks life’s journey – A path both real and virtual at once as only a True and rich life is.
  • 20. FOREWORD xiii With me she dies – our immortality inscribed in the fabric of the network. No duality of community here and Internet there – The Network is the Com- munity: One Web of life. Jim Coplien Mørdrup, Denmark 2 July 2008 en.wikipedia.org/wiki/James O. Coplien
  • 22. Kicking Butt with Java Technology on Symbian OS Mobile phones have changed the lives of billions of people and it’s clear that the revolution is just beginning. The quickly evolving world of mobile technologies is an exciting place for developers to create new applications to connect people and information. Java technology has enjoyed dizzying success in just under a decade in the mobile phone industry. As I write, more than 2.1 billion Java technology devices are deployed worldwide. At the same time, Symbian OS dominates the fast-growing smartphone market (with approximately 70%). This book is about the confluence of these two technologies and how to create your own powerful mobile applications. Now is a great time to be a mobile developer. You can help shape the coming landscape of advanced mobile applications by harnessing the power of both Java technology and Symbian OS. Learn the technologies, let your imagination run free, and have fun! Jonathan Knudsen jonathanknudsen.com Author of Kicking Butt with MIDP and MSA
  • 24. About This Book In 2001, Symbian published its first book devoted to Java on Symbian OS. Jonathan Allin’s Wireless Java for Symbian Devices provided an in-depth exposition targeted at programming PersonalJava on Symbian OS. In 2004, Martin de Jode’s Programming Java 2 Micro Edition on Symbian OS focused on programming MIDP, particularly MIDP 2.0 on Symbian OS. This book is the third in the series and there is no longer a need to explain what Java is. Therefore, the primary goal of this book is not to teach Java programming but to introduce you specifically to Java Platform, Micro Edition (Java ME) on Symbian OS. This book covers various topics from different perspectives. Our approach has been to start with the basics and prerequisites that are assumed in the rest of the book, then zoom into Java ME on Symbian OS specifically and then out again to discuss a few key areas of Java ME development today. We finish the book by delving deep down to expose what’s happening ’under the hood’. The book logically divides into four main parts: 1. Introduction to Java ME and programming fundamentals In Chapter 1, we describe the playground of Java ME on Symbian OS. It is recommended reading if you are not familiar with Java ME, Symbian OS or the smartphone industry. Chapter 2 is targeted at developers with no experience in Java ME. It sets the baseline information that is a prerequisite for reading the rest of the book, which assumes a certain level of knowledge of Java programming and, specifically, Java ME. Chapter 2 deals with the basic concepts of a MIDlet, LCDUI, MMAPI, and so on.
  • 25. xviii ABOUT THIS BOOK 2. Java ME on Symbian OS Part 2 assumes you are familiar with Java ME but are interested in learning about the Java ME platform hosted on Symbian OS. Chapter 3 explains what makes Java ME on Symbian OS different from other Java ME platforms; what makes it more powerful; and what else is unique to Symbian smartphones. Chapter 4 provides guidelines on how to handle differences between different Symbian smartphones. Chapter 5 provides an overview of development SDKs for Java ME on Symbian OS. 3. Drill down into MSA, DoJa and MIDP game development Part 3 expands the discussion into various key areas of Java ME development. We show how to leverage the power of MSA, give an introduction to how Java evolved very differently in the Japanese market, provide a glimpse of games development and equip you with best practices for your next application. 4. Under the hood of Java ME In Part 4, we reveal information that has rarely been exposed before. Chapter 10 explains the internal architecture of the Java ME subsys- tem as a Symbian OS component and Chapter 11 explains how Java ME on Symbian OS is tightly integrated with the native services. Appendix A introduces WidSets which is a run-time environment that makes use of the Java language and the Java ME platform. Appendix B introduces SNAP Mobile for game developers. This book contains a number of web addresses. If any of them are bro- ken, please consult the wiki page for this book at developer.symbian.com/ javameonsymbianos to find the updated location. We welcome beginners and professionals, third-party application developers and OEM developers working inside Symbian OS. Whether you’re just starting out in the exciting world of mobile development, want to learn Java ME or just like reading interesting stuff, this book is a mix of different topics that combine in the same way as a dish full of spices.
  • 26. Author Biographies Roy Ben Hayun Roy Ben Hayun has more than 10 years’ experience in various Java technologies in various software engineering roles: engineer, consultant, team lead, tech lead, and architect. He started his career in Lotus IBM, working on JDK 1.1.8, and then became a founding member of eMikolo networks, which pioneered P2P in the early days of Project JXTA. He later worked in various roles in other startup companies in Java SE, Java ME and Java EE. From 2002 until the end of 2007, he worked for Symbian, mostly in the Java group working on the design and implementation of JSRs and CLDC-HI VM tools support. In his last year at Symbian, he worked in the team supporting developers, during which time he authored a number of technical articles and white papers about run-time environments. After JavaOne 2007, Roy joined Sun Microsystems. He is currently working as a system architect in the Engineering Services group, which leads the development, marketing and productizing of Java ME CLDC and CDC on various platforms. Ivan Litovski Ivan joined Symbian in 2002, working first in the Java Team and later with the System Libraries, Persistent Data Services and Product Creation Tools teams. Ivan has 11 years of professional experience with Java, embedded software, information security, networking, scalable servers and Internet protocols. He enjoys solving difficult problems and research and devel- opment. He has authored several patents and papers in peer-reviewed,
  • 27. xx AUTHOR BIOGRAPHIES international journals. He holds a BSc in Electronics and Telecommuni- cations from the University of Nis, Serbia and is an Accredited Symbian Developer. Sam Mason Sam spent about two years working on a Java-based, multi-lingual, video-on-demand system for SingTel and other Asia-Pacific Economic Cooperation (APEC) telecommunications agencies. He has spent most of the last four years working with and learning about mobile phone tech- nologies, while picking up a couple of Java certificates and completing a Master of Information Technology (Autonomous Systems) at the Univer- sity of New South Wales along the way. He was a contributing author to Games on Symbian OS, writing the chapters on Java ME development and DoJa. He is an Accredited Symbian Developer. Daniel Rocha Daniel is a software engineer with 10 years’ experience in application development, having worked with web (Perl, ASP, PHP, JavaScript, JSP, Flash), enterprise (Java EE) and mobile software (Symbian C++, Java ME, Flash Lite, Python). He currently works as a Forum Nokia Technology Expert.
  • 28. Author’s Acknowledgements I feel vividly that this project was an amazing experience, primarily because of the people involved. I am blessed that there are so many people to thank – editors, contributing authors, reviewers, test readers and colleagues. Two of the people whom I had the honor to be guided by, Jo Stichbury and Jim Coplien, I met for the first time on the same day. The place was the ACCU conference in 2006 and the idea of writing the next book about Java ME for Symbian OS was too embryonic to be called ’an idea‘. Jo Stichbury (who had just returned from Nokia to Symbian) knew from her own authoring experience how to deliver a book from start to finish, and I am thankful for her personal guidance, her professionalism and wisdom as a technical editor, which has always managed to find the right solution at any time and on any matter. I am also thankful for meeting Jim Coplien, a truly visionary guy. Full of passion, equipped with his one-of-a-kind way of thinking, he has that rare long memory into the past of software engineering and a vision into the future of what will come out of all that we are currently doing. I am also in debt to the wonderful people who have contributed from their knowledge and experience: Ivan Litovski, Sam Mason and Daniel Rocha. Ivan has been a great friend from day one in the Java group at Symbian, and is a reviewer and contributing author to this book. Sam is a passionate mobile expert and the founder of Mobile Intelligence in Australia. I have been lucky enough to work with Sam on this book and to meet and become friends at JavaOne 2008. Daniel has constantly given this project wonderful support and his contributions, from his viewpoint inside Forum Nokia, have been invaluable. He came to the rescue on many occasions, and I’m truly appreciative of his hard work and energy.
  • 29. xxii AUTHOR’S ACKNOWLEDGEMENTS I’d also like to thank Mark Shackman for the pleasure of working with him during my four and a half years in Symbian. I am grateful for his constant insistence on the build up of logical arguments and perfect phrasing. Mark always delivers, and he manages to get the best out of hundreds (by now probably thousands!) of embryonic articles and book chapters. Thanks also to Martin de Jode for his valuable comments from his own experience in writing the second book in this series and much gratitude to Satu McNabb for her support and for always being there to help. I’d also like to acknowledge: • the people at John Wiley & Sons for working with us on this book with their high standards of professionalism and quality • my current group, Engineering Services in CSG, Sun Microsystems, which had the ability to see the future of Java from the remote distance of the 1990s and leads the way towards the next generation of Java technologies • the Java group in Symbian, of which I had the pleasure to be a member during most of my time in London • the Developers’ Consulting team and the Developer Product Market- ing team in Symbian • the many people who took time and patience to read all the sugges- tions and ideas that were yet to become chapters: Arnon Klein, Assaf Yavnai, Yevgeny (Eugene) Jorov, Jonathan Knudsen, Tomas Brandalik, Erik Hellman, Per Revesjö, Magnus Helgstrand, Lars Lundqvist, David Mery, and Emil Andreas Siemes • my parents and sister and all of my friends. Finally, this book is for my friend, partner and wife – Gabi – and our wonderful, beloved children, Noa and Ariel. For being blessed with everything that has happened and the things that are yet to happen. I hope you will enjoy reading this book.
  • 30. Symbian Press Acknowledgements Symbian Press would like to thank Roy, Sam and Daniel for the hard work and energy they’ve put into this book. Roy piloted this project with particular passion, and the results you hold before you are testament to his efforts and those he inspired in his co-authors. We were privileged indeed to put together such a team of talented writers and developers, and they in turn were fortunate to be able to draw on an extensive and experienced support crew, including Sam Cartwright, Martin de Jode, Ivan Litovski and Mark Shackman. We’d like to thank everyone involved in writing and reviewing the text of this book and in helping prepare the final manuscript. As usual, we’re grateful to the Wiley team (Birgit, Colleen and Claire), and to Sally Tickner and Shena Deuchars. In particular, Jo would like to thank Antony and Bruce for supporting the completion of this title.
  • 32. Part One Introduction to Java ME and Programming Fundamentals
  • 34. 1 Introduction to Java ME, Symbian OS and Smartphones Symbian OS is the operating system that powers more than 70% of smartphones worldwide. In addition to providing one of the industry’s most powerful native platforms for after-market applications, Symbian OS pushes the boundary further by allowing third-party software developers to work with a wide variety of mobile technologies including Symbian C++, Flash Lite, Python, POSIX-compliant C and, of course, Java ME – the focus of this book. The Symbian OS ecosystem has flourished over the last decade and, like any success story, is made up of many parts. Handset manufacturers, such as Nokia, use Symbian OS as the foundation stone of their user- interface platforms. In Japan alone, Symbian OS powers over 30 million phones that use NTT DoCoMo’s MOAP platform. The latest version, Symbian OS v9, is used in almost all of Nokia’s famous Nseries (feature- focused) and Eseries (business-focused) devices. In this chapter, we explore the Java Platform, Micro Edition (Java ME) technologies and see how they are uniquely positioned to address the on-going mobile phone software revolution. We start with a look at recent history, follow with a brief discussion of the Java language itself, the composition of Java ME and the benefits it inherits from Symbian OS. Finally, we wrap up with a look at the mobile phone market and get a glimpse of what the future holds. 1.1 2003: Rise of the Mobile One of the problems with turning points in history is that they’re often only apparent in retrospect. Don’t expect to see Monday 16 June 2003 in any documentary about days that changed the world because it’s not there – I checked. However, by the end of that day, a startling new
  • 35. 4 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES concept in mobile device hardware had been released, ushering in an era of exponential progress in mobile computing. On that rather special Monday, Nokia released a completely new type of mobile phone. The Nokia 6600 was the most advanced mobile phone anyone had seen, and it is still remembered today as a clear indication of where the future was headed. It had a large, 16-bit color screen, a four-way joystick for navigation and games, and a VGA, 640 × 480 camera for video recording and photography. The phone was a 2.5 G, Internet-enabled GPRS phone running Symbian OS v7.0 s with 6 MB of memory for storage, 3 MB RAM and had Bluetooth wireless technology connectivity. It was also easy to use and looked great at the time (it looks like a bit of brick today, as you can see from Figure 1.1). Figure 1.1 Nokia 6600 This new device was clearly going to cause quite a stir, so the Nokia marketing team came up with a special phrase just for the launch – something that was prophetic and sounded really cool: Image is Power. Less important at the time but far more relevant to us today, the Nokia 6600 was the first mobile phone to come with the very latest in Java technology – the Mobile Information Device Profile (MIDP) 2.0, which had recently been finalized. Java ME was already dominating the mobile software market; it was about to take a huge leap forward and the Nokia 6600 was the springboard. Even today, I keep my Nokia 6600 in a special place and consider it with reverence. In 2003, while the rest of the software industry was dragging itself out of the Dot-com Bust, the constrained-device development sector was at the start of a vertical rise. Hundreds of business applications had already been written and shipped in expectation of an amazing shift in the way people did business. The momentum for mobile hardware and software
  • 36. 2003: RISE OF THE MOBILE 5 built over the years following the release of the Psion Organiser 1 in 1984 and, by 2003, millions of portable information devices had sold around the world. These included pagers, iPods and generic MP3 players, personal organizers (both the original handheld computers and the latest PDAs), Game & Watch1 devices and, of course, mobile phones. People were getting busier and more ‘connected’. Business was becom- ing more demanding, requiring decisions faster, for higher stakes, and 24 hours per day. It was an exciting time and mobile technology, it seemed, had all the answers. Except that it didn’t work out that way. What the oracles didn’t predict was that while there would be a worldwide explosion in the use of mobile phones, they would largely be used to send text messages, buy ringtones and wallpapers, and take photos or video. People didn’t buy them to do business after all. They bought them as personal statements and as fashion accessories. They bought them as a convenient communications device. They also bought games. Quite a lot of games, actually. Thousands of titles were developed and sold directly to the public or shipped on devices. The market for mobile phone games quadrupled between 2002 and 2003 and it is estimated that over 50 million phones that allow after-market game installation were shipped in 2002 alone. Fast forward five years to 2007 and there are nearly three billion mobile phone subscribers worldwide.2 The mobile phone has now become the personal information accessory of choice – everyone is ‘texting’ using appalling new pseudo-grammars (wch is gr8 if u cn do it), crowded buses sound like call centers, the mobile games market has exploded into the public eye with huge titles, such as The Sims 2,3 and in many parts of the world a new kind of digital life has emerged and become the norm. The newest devices are a far cry from the Nokia 6600. January 2007 saw the iPhone launched into the marketplace, followed closely by the Nokia N95 in March of the same year with the slogan ‘It’s what computers have become‘. In October 2008, the T-Mobile G1 became the first smartphone to use the Android platform. Clearly innovation and demand caused many changes in just those five years! Let’s look at some of the figures to put this into perspective – in 2007, mobile handset annual sales exceeded 1 billion units for the first time. That means that more than 2.7 million phones were sold each day. Moreover, sales of Nokia handsets alone in 2007 were larger than the entire industry in 2001 and 2002! Figure 1.2 charts annual sales and shows how the market almost tripled over a six-year period, with an annual growth rate of nearly 20%. 1 If you missed the 1980s, find out about the Game & Watch craze at en.wikipedia. org/wiki/Game %26 Watch 2 Global cell phone penetration reached 50% in November 2007, according to www.reuters.com/article/technologyNews/idUSL2917209520071129 3 www.thesims2.com
  • 37. 6 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 00 200,000 Sales (000s) 400,000 600,000 800,000 1,000,000 1,200,000 Nokia Motorola Siemens Samsung Sony Ericsson LG Others Figure 1.2 Annual number of devices sold4 Add five more years and it is 2012. At current growth rates, it is estimated that smartphones will comprise nearly 30% of the market (compared to 10% in 2007) and that subscriber levels worldwide will reach 3.5 billion. Just think about that number – we can’t really conceive figures like this in our minds, but this is a really big market. Eight out of ten devices support some form of Java-based technology – quite an opportunity for the budding technically-minded entrepreneur. If you sell every thousandth person a $1 Java ME MIDlet, pretty soon you’ll have made over $3 million – job done, time to retire. 1.2 2008: Mobile Generation Our world has changed. Like all great upheavals, the ‘rise of the mobile’ has had both positive and negative effects on us. As a society, we’re irrevocably addicted to our information devices now. Everywhere we look we see iPod MP3 players, Tom-Tom personal navigation devices, mass- market feature phones, smartphones, managers who can’t get off their Blackberries, people talking while walking, people setting up meetings, messaging, listening to music, reading, using devices for entertainment, organization, romance, learning. It goes on and on. Mobile information devices are the instruments of an unprecedented wave of fundamental social change. The very basis upon which we inter- act with each other has suddenly changed without notice and the results are not necessarily all good. SMS bullying is on the rise; onboard cameras have changed our expectations of personal privacy; train carriages are 4 java.sun.com/developer/technicalArticles/javame/mobilemarket
  • 38. MEET THE HOST – SYMBIAN OS 7 like mobile offices; and I’ve yet to go to a funeral where someone’s mobile doesn’t ring during the eulogy. It’s fashionable to talk about people being more ‘connected’, as I did above, but a world full of people with iPods and earphones can feel like an increasingly isolated one. Even our basic standards of interaction are affected – people think nothing of sending text messages while talking to you and the legalities involved with using evidence from mobile phones are still being ironed out. On the positive side though, the plethora of lifestyle applications and services available on mobile phones now definitely makes life a lot more interesting. GPS and navigation applications make it hard to get lost in most places in the world and you can send goodnight kisses to your kids via MMS from wherever you end up! Messaging is by nature asynchronous so you don’t have to deal with inter-personal communication immediately any more, which allows you to manage your time better. And if you have a two-hour train trip to work why not listen to a podcast on some topic of interest instead of reading the newspaper? I was thinking the other day about the phrase ‘Information is power’ and about mobile phones, games, Symbian OS, business applications, Nokia, the future, mobile phones (again), robots, Linux and just general technology. As sometimes happens, I had an acronym attack and real- ized that information is indeed POWER because it affords us Pleasure, Opportunity, Wealth, Experience and Reputation. To me, this acronym spells out five very good reasons to start learning Java ME today. If you’re not yet convinced, stick with me, since the rest of this chapter, and the book, considers the use of Java technology, specifically the Java ME platform, as the candidate to address the growing hardware diversity and the challenges of the future. 1.3 Meet the Host – Symbian OS Symbian OS is a market-leading, open operating system for mobile phones. Cumulative sales of Symbian smartphones reached 226 million units worldwide in June 2008. By the end of that month, more than 250 different models of smartphone had been created by handset manufactur- ers licensing Symbian OS; eight handset vendors, including the world’s five leading vendors, were shipping 159 mobile phone models.5 On 24 June 2008, the Symbian Foundation was announced6 and, at the time of writing, it is on track to create an open and complete mobile software platform, which will be available for free, enabling the whole mobile ecosystem to accelerate innovation. The Symbian Foundation provides, manages and unifies Symbian OS, S60, MOAP(S) and UIQ for its members. It is committed to moving the platform 5 www.symbian.com/about/fast.asp 6 www.symbian.com/news/pr/2008/pr200810018.asp
  • 39. 8 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES to open source within two years of the Foundation’s announcement. See www.symbianfoundation.org for more information. There have been many operating systems available over the last decade – so what is it about Symbian OS that has enabled it to stay so far ahead of the competition? The design of Symbian OS is highly modular, which means that it is constructed from well-defined, discrete parts. Most Symbian OS components expose a Symbian C++ API7 and a large number of these APIs are available to third-party application developers. At a high level, Symbian OS can be thought of as a layered model, with a flexible architecture that allows different UI layers to run as platforms on top of the core operating system. That is, Symbian OS provides a framework that supplies a common core to enable custom components to be developed on top of it. The generic UI framework of Symbian OS supplies the common behavior of the UI and supports extension by licensees who define their own look and feel. For example, the S60 platform, supplied by Nokia, sits on top of Symbian OS. S60 is the world’s most popular smartphone platform, and is currently used by Nokia, LG and Samsung. Almost 180 million S60 devices had been shipped by S60 licensees by the end of June 2008.8 The power and configurable design of Symbian OS are the key con- tributing factors to its success. Today, Symbian OS devices are being sold in every market segment as you can see from the variety of hardware shown in Figure 1.3. If you want to find out more about Symbian and Symbian OS, there are a range of resources including books from Symbian Press, available from developer.symbian.com/books, and www.forum.nokia.com. If you are new to Symbian OS and interested in a slightly more detailed overview about Symbian OS, a recommended resource is the first chapter of [Babin 2007].9 Walkman® Sport Remote Control Music Multimedia Waterproof Mobile TV Biometrics Hybrid Business Music Fashion Imaging Simple Figure 1.3 Symbian OS is everywhere 7 Symbian C++ is a dialect of C++ with idiomatic extensions. 8 www.forum.nokia.com/main/platforms/s60 9 The chapter can be downloaded from developer.symbian.com/main/documentation/ books/books files/dasos.
  • 40. WHAT IS JAVA? 9 1.4 What Is Java? Let’s jump back to August 1998. The word ‘Java’ is synonymous with the Internet in the public mind. The most common question at the time is ‘What is Java?’ If you can explain that then you have a job. The company behind Java technology is Sun Microsystems, which was founded in 1982 and today provides a diversity of software, systems, services, and microelectronics that power everything from consumer electronics, to developer tools and the world’s most powerful data centers. Other than Java technology, the core brands include the Solaris operating system, the MySQL database management system, StorageTek10 and the UltraSPARC processor. In the early 1990s, Sun formed the ‘Green Team’ whose job it was to prepare for the future. One of the team members was James Gosling (known as ‘the father of Java’). The aim was to create a software platform that could run independently of the host platform – and the ‘Write Once Run Anywhere’ mantra was created. By creating a controlled virtual environment, or machine, software written on one hardware platform could run unaltered on any other hardware platform. The Java programming language was introduced by Sun Microsystems in 1995 and is designed for use in the distributed environment of the Internet. It was designed to have familiar notation, similar to C++, but with greater simplicity. The Java programming language can be character- ized by: • Portability: Java applications are capable of executing on a variety of hardware architectures and operating systems. • Robustness: Unlike programs written in C++, Java instructions cannot cause a system to ‘crash’. • Security: Features were designed into the language and run-time system. • Object orientation: With the exception of primitive types, everything in Java is an object in order to support the encapsulation and message- passing paradigms of object-based software. • Multithreading and synchronization: Java supports multithreading and has synchronization primitives built into the language. • Simplicity and familiarity: This is, of course, relative to C++. Don’t imagine that Java can be learned in a day. Java is a technology rather than just a programming language. It is a collection of software products and specifications that provide a system 10 StorageTek is a tape-based storage solution from Sun. See www.sun.com/storagetek for more information.
  • 41. 10 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES for development and deployment of cross-platform applications. After you’ve worked with Java technologies for a while, you’ll realize that they’re also much more than that – they’re a way of thinking about software systems and how they work together. Java is an interpreted language. This means that program code (in a .java source file) is compiled into a platform-independent set of bytecodes (a .class file) instead of into machine-specific instructions (which is what happens to a C program). These bytecodes are then executed on any machine that hosts a Java platform, a software-only platform that runs on top of a native platform (the combination of an operating system and the underlying hardware). A Java platform is divided into two components: • The Java virtual machine (JVM) that executes the Java language bytecode can be ported to various native platforms. • The collection of Java APIs are ready-made software libraries that provide programming capabilities. Together, the JVM and the APIs form the Java platform which insulates an application from the native platform. This was a remarkable achievement but it was not achieved without cost. Support for low-level power and fine-grained control was sacrificed, as well as explicit memory management and pointers. It was almost impossible to write Java software that would corrupt memory, but pro- grammers couldn’t dispose of memory themselves (to the horror of many there was a new keyword but no delete); instead it was handled auto- matically by the run-time environment using the ‘garbage collector’. This was part of the environment that monitored object references at run time and would decide when to reclaim allocated memory on behalf of the program. Added to all of these new ideas was the ‘applet’. This probably had the largest role in making Java a 1990s buzz word. Java applets are small programs that can run inside a web browser. Code resides on a remote server, is downloaded over the network and is executed locally inside a ‘sandbox’, restricting operations to those considered ‘safe’. At the same time, class file verification and a well-defined security model introduced a new level of software security. Java applets had limited use and were quickly outdated by the rise of Flash as a browser-based, client-side technology but applets had served a special role in the Java world. They demonstrated the power of this new language called Java, raised awareness of the Internet and helped create a strong worldwide Java developer base that today numbers over six million. As time went on, Java moved to have more of a focus on desktop applications and then server applications: suddenly, everyone was talking
  • 42. WHAT IS JAVA? 11 about Enterprise Java Beans. Following this was a big leap to smart cards and the emerging market with the rise of mobile phones. Sun quickly realized that while there were Java solutions for all of these areas, no one set of technologies could adequately address all requirements. It was at this point that Java was separated into the four core technologies that we see in Figure 1.4.11 Optional packages Servers & enterprise computers Servers & personal computers High-end PDAs, TV set-top boxes & embedded devices Mobile phones & entry-level PDAs Smart cards Optional packages Optional packages Optional packages MIDP Java Platform, Micro Edition (Java ME) CLDC JVM CDC Java Card Card VM JVM JVM JVM Foundation Profile Java 2 Platform, Enterprise Edition (Java EE) Java 2 Platform, Standard Edition (Java SE) Personal Profile Personal Basis Profile Figure 1.4 Java technologies The Java Platform, Micro Edition (Java ME) fork was created to address the constrained-device market. Java Card is a separate technology that has nothing to do with Java ME. These days, most mobile phones include some kind of Java technology. Blackberries run a superset of Java ME, extended with RIM libraries. Google’s Android platform uses a ‘Java-like’ platform and even Microsoft’s Windows Mobile and Pocket PC support Java ME. Nokia’s Series 40 phones, which form the backbone of the feature phone market, all have support for Java ME as do all phones running Symbian OS.12 If you want to know more about the other Java technologies or learn about the Java language, this is probably the wrong book for you. If that’s what you want, then probably the best place to start learning about Java 11 Java ME consists of two ‘flavors’, which is why there are five groups in Figure 1.4. 12 Except for MOAP(S), which has DoJa; it is very similar to Java ME, but is not strictly the same.
  • 43. 12 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES is straight from the creator himself, James Gosling in [Arnold, Gosling and Holmes 2005]. From this point on, we’re only going to talk about ME – Java ME! 1.5 Java ME Sun launched a research and development project called Spotless in the 1990s in order to produce a JVM that could run on devices with small memory and power budgets, intermittent or non-existent connectivity, limited graphical user interfaces, divergent file system concepts (if any) and wildly varying operating systems. This could be anything from set-top boxes to Internet phones, parking meters, digital TVs, vending machines, automotive interfaces, electronic toys, personal organizers, household appliances, pagers, PDAs, high-end smartphones and mass-market feature phones. The result of the project was the Kauai virtual machine (KVM). This was a cut-down version of the JVM that required less than 10% of the resources needed for the desktop standard edition of Java. This was achieved by targeting the size of the virtual machine and its class libraries, reducing the memory used during execution and by creating a pluggable architecture that allowed sub-systems of the KVM to be tailored to specific device architectures. With such a diverse range of hardware targets, it was decided to adopt a more flexible model for Java ME and the final result consisted of three high-level components that together make a wide range of solutions possible. Java ME consists of: • configurations • profiles • optional packages. We’ll look at each of these in detail shortly. In order to allow for future expansion and new technologies, additions to the Java ME technologies are managed through the Java Community Process13 in the form of Java Specification Requests known as JSRs. Each JSR is reviewed by panels of experts and public drafts allow a wide range of interested parties to contribute to the process. JSRs are usually referred to by their name and number; for example, JSR-82 is the specification request for the Bluetooth API. A lot of functionality had to be removed from the desktop Java Standard Edition (Java SE) to make Java ME. For example, some things that are missing include: 13 www.jcp.org
  • 44. JAVA ME 13 • reflection • thread groups and advanced thread control • user-defined class loaders • the Java native interface (JNI) • automatic object finalization. Compatibility played a large part in the design of Java ME. In order to maintain as much compatibility with Java SE as possible, the Java ME packages were divided into two logical groupings: those that were specific to Java ME (packages whose names start with javax) and those that were a subset of their Java SE counterparts which followed the same package-naming convention. One of the strongest features of the Java language is its security – both at the application layer and within the virtual machine itself. The VM security layer ensures that bytecodes are valid and safe to execute. This works really well on servers and the desktop environment but not so well on mobile phones with small processors and small power and memory budgets. The solution was a hybrid approach using the concept of pre-verification performed offline as part of the build process on the development machine. Only after VM acceptance may the bytecodes execute on the host hardware. 1.5.1 Configurations Configurations define the lowest common denominator for a horizontal category of devices that share similarities in terms of memory budgets, processor power and network connectivity. A configuration is the spec- ification of a JVM and a base set of necessary class libraries which are primarily cut-down versions of their desktop counterparts. There are currently only two configurations: • The Connected Limited Device Configuration (CLDC) was aimed specifically at mobile phones, two-way pagers and low-level PDAs. • The Connected Device Configuration (CDC) was aimed at devices with more memory, better network connectivity and faster processors. We should be clear, however, that the CDC profile doesn’t really have a role in the mobile phone space at this time. Although high-end devices, such as Symbian OS phones, can accommodate a CDC-based Java platform, the consumer market today is based on MIDP/CLDC applications, so CDC is not within the scope of this book.
  • 45. 14 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES Table 1.1 CLDC 1.1 Packages Package Description java.io Basic classes for I/O via data streams, Read- ers and Writers java.lang Reduced math library, threads and system functionality, fundamental type classes java.lang.ref Support for weak references which allows you to hold a reference to an object even though it is garbage collected java.util The Vector and Hashtable classes, basic date and calendar functionality and a pseudo random number generator which is great for games javax.microedition.io CLDC specific interfaces and factories for datagrams, connection stream etc. Imple- mentation deferred to profiles. So far there have been two versions of the CLDC,14 the latest being CLDC 1.1. Most mobile phones shipped since 2003 contain version 1.1 of the CLDC. CLDC 1.1 (see Table 1.1) includes, amongst other updates, support for floating-point operations with the introduction of the Float and Double classes, thread naming and interrupts. The total minimum memory requirement was also lifted from 160 KB to 192 KB. While the discussion so far has focused on mobile phones, the CLDC is not just for phones. As we’ll see in the following section, it forms the foundation for a number of profiles that target completely different device families. 1.5.2 Profiles Profiles sit on top of a configuration and allow it to be adapted and specialized for a particular class of devices in a vertical market such as mobile phones. A profile effectively defines a contract between an application and a set of devices of the same type, usually by including class libraries that are far more domain-specific than those available in any particular configuration. Figure 1.5 shows the three profiles that currently extend the CLDC. The Mobile Information Device Profile (MIDP) is most relevant to our work here; the Information Module Profile15 (IMP) targets small devices that may have no user interface at all, such as parking meters, call boxes, and 14 See the white paper at java.sun.com/j2me/docs/pdf/CLDC-HI whitepaper-February 2005.pdf . 15 java.sun.com/products/imp/index.jsp
  • 46. JAVA ME 15 Mobile Information Device Profile Information Module Profile CLDC Digital Set Top Box Profile Figure 1.5 CLDC profiles (adapted from [Ortiz 2007, Figure 5]) vending machines; and the Digital Set-Top Box Profile is aimed squarely at the cable television market. CLDC is also used by the proprietary DoJa profile for i-mode devices from NTT DoCoMo, which dominates over 50% of the Japanese market. We talk more about DoJa in Chapter 7. Applications that use the MIDP libraries are called MIDlets. MIDP defines the core functionality that mobile applications can leverage (for example, the user interface (UI), local storage and network connectivity) and also specifies application lifecycle management. The original version of MIDP was started in November 1999; even though it did not specifically provide libraries for games, that didn’t stop hundreds of titles being written and sold worldwide. In fact, so successful was MIDP 1.0 that work began in 2001 on defining the second version – MIDP 2.0. The MIDP 2.0 libraries include a high-level UI API with support for standard widgets (textboxes, check boxes, buttons, etc.) and a low-level UI API supporting graphics contexts aimed mainly at games develop- ment. The low-level API includes standard routines for creating graphics primitives (lines, polygons, arcs, etc.) as well as supporting clipping, full-screen canvases, regions, image manipulation, fonts, brushes, colors, and off-screen buffers. Support for local persistence on the MIDP is pro- vided through the record management system (RMS). The CLDC Generic Connection Framework was extended with additional connections, such as HTTP, TCP and UDP. MIDP 2.0 also introduced timers, the Media API (a subset of the optional JSR-135 Mobile Media API) and the Game API package which enables the development of rich gaming content for mobiles. 1.5.3 Optional Packages The optional general-purpose APIs provide a set of functionality that is not specific to any particular class of devices and have allowed the Java ME platform to evolve and embrace emerging technologies. They add extra functionality to a profile and are sometimes incorporated into the profile as the technology matures. The Mobile 3D Graphics for J2ME API (JSR-184) and the Location API (JSR-179) are good examples of optional packages. It is common to simply use the term ‘JSR’ when referring to
  • 47. 16 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES the set of packages a device may support, although configurations and profiles are actually all the product of particular JSRs. Java ME got off to a bumpy start – the realities and pressures of business competition, largely due to the phenomenal rise of the mobile games industry, led to a wide disparity in optional JSR support across the set of available devices in the market. There was no standard set of JSRs available, some implementations didn’t comply with the defined JSR requirements and some only offered partial compliance; it was extremely difficult even to find out which JSRs were supported on any particular handset. Sometimes irregularities occurred within the same family of mobile phones from the same manufacturer, with APIs missing for no obvious reason. Manufacturers would also add their own proprietary APIs to allow non-standard functionality or extra functionality that wasn’t covered by the standard JSRs. While that addressed the short-term need, such libraries had to stay around for compatibility reasons long after they had been superseded. The net result was a series of device-specific workarounds leading to complex code forks and build trees for Java ME applications – particularly games which would typically target hundreds of handsets at any one time. Game development houses wrote entire libraries trying to work across these heterogeneous environments and then had to work to recoup the investments made. This unfortunate phenomenon is known as ‘fragmen- tation’ and the ‘write once, run anywhere’ mantra became ‘write once, debug everywhere’. This had an extremely detrimental effect on the time to market of Java ME applications and games. 1.5.4 Tackling Fragmentation Something had to be done. The first attempt to tackle fragmentation was JSR-185, Java Technology for the Wireless Industry (JTWI), which specified a minimal level of optional API support for JTWI-compliant devices. Release 1 of the JTWI was approved in July 2003 and defined three categories of JSR: mandatory, conditionally required, and minimum configuration. A handset that declares itself to be JTWI-compliant has CLDC 1.0 or CLDC 1.1 as a minimum configuration and must support at least: • MIDP 2.0 (JSR-118) • Wireless Messaging API (JSR-120). If the device allows MIDlets to access multimedia functionality via APIs, then the JTWI also specifies that the Mobile Media API (JSR-135) is required (i.e., it is conditionally required). JTWI also defined a number of implementation parameters for these JSRs, including support for JPEG encoding, MIDI playback, the number of
  • 48. WHY USE JAVA ME ON SYMBIAN OS? 17 record stores allowed in the RMS, Unicode support and some threading requirements. While this was a great start, more needed to be done. JTWI served as a necessary consolidation point in the evolution of the mobile industry, but there were still many JSRs in the world of Java ME. The Mobile Services Architecture16 (JSR-248, MSA), finalized in December 2006, mandated that an MSA-compliant device is JTWI- compliant and implements a much wider range of JSRs. The specification defines two categories of MSA, known as Full MSA and MSA Subset (see Figure 1.6). (a) (b) Figure 1.6 Mobile Services Architecture: a) Full MSA and b) MSA subset (adapted from [Ortiz 2007, Figure 3]) MSA is a huge step forward and the number of MSA-compliant devices available in the market is increasing all the time. Have a look at the Java ME device registry at Sun, which lists some of them, to see how MSA has raised the bar. (For more information on MSA, see Chapter 6.) 1.6 Why Use Java ME on Symbian OS? Why not just use Symbian C++? That’s a good question. To answer it, we need to look firstly at what people do with their smartphones and then how it is achieved technically. 16 jcp.org/en/jsr/detail?id=248
  • 49. 18 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES web surfing once a day primary camera primary MP3 player download music willing to pay for mobile TV % mobile users 0% 10% 20% 30% 40% 50% 60% 70% 80% Figure 1.7 Smartphone usage17 Figure 1.7 shows the results of a survey of how people are willing to use their smartphones. In addition, if we were to ask a random sample of people in the street what they do regularly, we’d also expect them to include activities such as playing games, sending text messages, sending pictures, social networking, checking match scores, finding directions, watching videos, checking weather or traffic – and annoying other people on buses. It is clear that there are many uses for smartphones, most of which involve downloading mobile content, such as installable applications and games, purchasing multimedia, such as music, videos, and mobile TV, or simply downloading web pages while browsing the Internet. ‘Content’ is the key word here. A high-end mobile platform cannot exist without content; in its absence there’s nothing that compels the user to buy a high-end device. Who would buy a fully featured smartphone to make voice calls and send SMS messages only? In theory, it is possible to restrict all installable content to that created using Symbian C++, in order to control where it comes from. That just results in a ‘walled garden’, which goes against the principle of Symbian OS as an open platform, because millions of talented engineers who are not well-versed in Symbian C++ cannot contribute to the platform and any existing content not written in Symbian C++ cannot be reused. That would be unduly limiting, so the Symbian strategy is to enable environments that maximize third-party developer contributions and content re-use. Apart from Java ME, the other run-time environments available include POSIX-compliant C, Flash Lite, Silverlight, Python, Ruby, Web Runtime, and WidSets.18 So a better question is ”when should I use Java ME on a highly powerful and open environment, such as Symbian OS?”. To work out the answer to 17 ‘Welcome to the Smartphone Lifestyle’ by Nigel Clifford CEO of Symbian Ltd, Symbian Smartphone Show, 2007 keynote address 18 developer.symbian.com/main/documentation/runtime environments
  • 50. WHY USE JAVA ME ON SYMBIAN OS? 19 that question you need to do a cost–benefit analysis which covers areas such as the available skills in your organization, functional feasibility in Java, development effort in Java compared to other options, performance considerations, and cross-platform requirements, all framed by the profile of your application. Let’s take a quick look into how the ‘leading Java platform’ strategy translates into technical support. The Symbian implementation of the Java ME technology platform is best of breed, so we’ll run through some of the benefits that Java ME enjoys under Symbian OS. Optimized Performance The most common criticism leveled at Java ME (or any version of Java) is that it doesn’t execute as fast as native code because it’s an interpreted language (in principle, the JVM interprets Java bytecodes at run time). This is mentioned so often, you’d think that everyone was writing real-time satellite control systems instead of games for mobile phones. Java runs much faster than it used to: the KVM was placed in the Java museum long ago. Symbian replaced the KVM with CLDC-HI HotSpot, in which the application bytecode is compiled to the ARM instruction set on the fly. As a result, Java applications received a major performance boost that was not only measurable by objective benchmarks but also by the user – which is the real benchmark in most mobile applications. No Hard Limits on Computing Resources On most feature phones, the memory assigned to Java is fixed when the device is created, which causes a wide variety of challenges for advanced application development on these platforms. Symbian OS does not place arbitrary constraints on available memory, storage space, number of threads, number of connections, or JAR size. Within the bounds of available resources, there are no limits – the heap can grow and shrink as required. Consistency and Variety of JSRs Probably the greatest benefit of working with Java ME on Symbian OS is the consistency and variety of JSRs. The problems of JSR fragmentation are largely a thing of the past. The set of optional JSRs supported has grown with each new version of the operating system and the latest smartphones expose some of the very latest in technology directly to MIDlets. With this wide variety comes both implementation consistency and the ability to leverage the best of the operating system. For example, releases of Symbian OS v8.0 and later support the full Mobile Media API (JSR-135) and provide native support for OpenGL ES 1.0 (an abstraction layer for the Mobile 3D Graphics API (JSR-184), meaning that your MIDlets auto- matically benefit from hardware acceleration on the handset). Symbian
  • 51. 20 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES Table 1.2 JSR Support on Symbian OS JSR Nokia 6,600 Nokia N70 Nokia N96 Symbian OS version v7.0 s v8.1a v9.3 Release Date 16 June 2003 27 April 2005 11 Feb 2008 CLDC 1.0/1.1 1.0 1.1 1.1 MIDP 2.0/2.1 2.0 2.0 2.1 Bluetooth 82 ✓ ✓ Mobile Media (MMAPI) 135 ✓ ✓ ✓ Wireless Messaging 120 ✓ ✓ ✓ Wireless Messaging 20519 ✓ File and PIM 75 ✓ ✓ Mobile 3D Graphics (M3G) 184 ✓ ✓ JTWI 185 ✓ ✓ Web Services 172 ✓ ✓ Location API 179 ✓ Security and Trust Services 177 ✓ SIP API 180 ✓ Scalable 2D Vector Graphics 226 ✓ Advanced Media Supplements 234 ✓ MSA 248 MSA Subset OS v9 enhances a number of existing APIs and adds many more. The net result is a rich diversity of functionality optimized for performance and memory efficiency. Table 1.2 shows a snapshot of how JSR support under Symbian OS has evolved over the last few years. Summary When you develop using Java ME and Symbian OS, you are combining the world’s leading smartphone operating system with the most successful mobile phone development platform to date. Symbian OS brings consis- tency, performance, reliability and variety to its Java ME offering while at the same time removing the most common limitations of other operating systems. 19 JSR-205 was an update to JSR-120 that added programmatic support for MMS.
  • 52. JAVA’S PLACE IN THE SUN 21 There are an enormous number of Java ME applications already out there – far exceeding the number of native Symbian C++ applications ever built. The number of Java developers for the mobile environment is also increasing and is undoubtedly bigger than the army of Symbian C++ developers. Having said all this in praise of Java ME, do keep in mind that there are times when you need to go native, times when you need the maximum speed, real-time performance, fine-grained control or bare-metal access to native services that are not exposed in Java. When you need low- level power, tight integration with the operating system, or advanced features that are not scoped by Java, then your best option is probably Symbian C++. For example, Symbian OS native services allow you to develop hooks into the TCP/IP stack and plug extensions to the Symbian OS Messaging component. Java ME is simply not designed for such requirements. For a further comparison of native Symbian C++ and Java ME on Symbian devices, please see [Mason and Korolev 2008]. 1.7 Java’s Place in the Sun There can be no discussion of Java ME without a section about mobile games. This is such a booming and exciting industry that Symbian has already published an entire book just on mobile game development [Stichbury 2008]. Almost as soon as the first Java-enabled handsets reached the public, the mobile games explosion was under way. While MIDP 1.0 was a fantastic start, it was the release of MIDP 2.0 with its Game API that really made the difference. Suddenly, there was a GameCanvas class, support for basic sounds via tone generation, support for sprites and collision detection, the ability to take over the entire screen and efficient mechanisms for representing large animated backgrounds and detecting multiple keystrokes during the main game loop. It was pretty clear that mobile games were out-selling every other type of application across all platforms and the pace was accelerating. A new type of gamer emerged who was very different from the traditional hard-core console jockeys. They didn’t sit in darkened rooms eating pizza and pretending to be someone else online – instead people played games on their mobiles while waiting for a bus, walking around or just sitting in a park. In a major research project for N-Gage,20 one of the key findings was that mobile games were played almost as much on the move and when waiting as when at home. In this market, games needed to be designed to be played in short bursts, to be paused and re-started without warning, to deal with sudden 20 ‘Evolution of Mobile Gaming’, available from Forum Nokia (www.forum.nokia.com).
  • 53. 22 INTRODUCTION TO JAVA ME, SYMBIAN OS AND SMARTPHONES loss of battery power or to be interrupted by an incoming call. Ad-hoc networks could be created with Bluetooth wireless technology for multi- player games and, with the introduction of the Mobile 3D Graphics API (JSR-184,21 also known as M3G), artists and designers could create game assets using industry-standard 3D modeling tools and developers could include and animate them in 3D scenes on actual handsets. On Symbian OS phones, the M3G implementation leverages the native support for OpenGL ES that comes with the operating system. Of course there were problems. Mobile phones, even high-end ones, have limited power, memory, processing and screen area. Floating-point operations present a significant hurdle to be overcome when trying to perform 3D graphics calculations on a phone. It was quickly apparent that JSR-184 could not provide acceptable frame rates in the absence of hardware acceleration. Now that a few more years have passed, it’s pretty common to see mobile phones with dedicated hardware for graphics and floating-point calculations and the latest Symbian OS phones natively support OpenGL ES 1.1. The introduction of OpenGL ES 2.0 will change the entire mobile gaming landscape; it has support for the programmable graphics pipeline (i.e. shaders) and there is already a JSR in progress to work with it – the Mobile 3D Graphics API 2.0 (JSR-297).22 Realizing that mobile multiplayer game-play was a huge potential mar- ket, Nokia launched the Scalable Network Application Package (SNAP) framework23 in 2003. Network operators love it because it generates revenue by increasing bandwidth usage. SNAP 2.1, the latest version of the SDK, has only just been released at time of writing; it is discussed in Appendix B. We also discuss general games development in more detail in Chapter 8. 1.8 Routes to Market So you bought this book, learned all about Java ME application devel- opment, designed and built the killer Java ME mobile application and you’re ready to sell – now what? How do people find and buy mobile applications? In 2006 alone, roughly $2.5 billion dollars’ worth of games were sold worldwide so let’s discuss how you can grab a piece of it. There are currently two main ways to get your applications working for you. The first way is to make a deal with a network operator or carrier for a slot on their ‘deck’. The deck is a space on their mobile portal where the top mobile applications (usually games) are made available for 21 For a great introduction to JSR-184, check out developers.sun.com/mobility/apis/ articles/3dgraphics. 22 www.jcp.org/en/jsr/detail?id=297 23 www.forum.nokia.com/main/resources/technologies/snap mobile
  • 54. ROUTES TO MARKET 23 subscribers to download. The subscribers usually have some deal where they can download a certain number of applications per month and it simply gets added to their bill. This is a really difficult path to tread. To start with, you need to be a tough negotiator with a strong sales pitch and a business plan. Secondly, operators tend to look for applications that are unique in some way so that they will sell well, and there are already thousands of titles out there so a mobile version of Frogger probably isn’t going to cut it. Thirdly, operators tend to avoid making deals with small-timer ’unknown’ developers – not only because of quality concerns but also because when something does go wrong, it is the operator that must deal with the irate customer not the developer. Lastly, in order to mitigate some of this risk, operators often insist that MIDlets be Java Verified, which can introduce some additional overhead that needs to be taken into consideration. However, let’s say you ignore all of this and go ahead anyway. The chances are pretty good that the last hurdle will tell you if your application is truly ready. The Java Verified program24 is a quality assurance program run by third-party testing houses that ensure MIDlets meet well-defined and accepted sets of guidelines. MIDlets that are Java Verified can use the Java Powered logo on their splash or ‘about’ screens which marks the software as having passed a rigorous testing process. This conveys a level of trust in the quality of the software that is widely regarded in industry. A better way for small developers is to work with content aggregators, companies such as www.gamemobile.co.uk, www.handango.com and www.glu.com with online portals hosting thousands of mobile applica- tions available for sale straight to the public. The details of the process varies, but generally speaking, they host your software for free (or a very small fee) and then take a cut of each sale. There are distinct advantages to this. The content aggregators handle marketing, billing, payments and invoicing; they are already well known, have disaster recovery plans for their server farms and are likely to have large volumes of Internet traffic which translates directly into increased sales. They also tend to be far more interested in the application than in the fact that you’re a small business. Other areas that need thinking about include a support framework for your application. This can involve taking support calls, responding to FAQs or emails, forum administration, distributing patches, releasing upgrades and, worst of all, processing refunds. We hope this won’t happen too often and the best way to prevent it is to get hold of hardware and test it thoroughly. For further information about taking your application to market, we recommend ‘Getting to Market’, a booklet published by Symbian Press, which can be downloaded from developer.symbian.com/ booklets. 24 www.javaverified.com
  • 55. Other documents randomly have different content
  • 56. CHAPTER XXV Homeward Bound—The Stowaway Having cleared the English customs and with a clean bill of health, we were ready to sail. The pilot was on board and his boat's crew had a line fast through the stern chalk so that we could tow them with us clear of the channel reef. Once clear of the reef all that remained to do was to haul the pilot boat alongside and have this servant of His Majesty climb down the Jacob's ladder and into the boat which would bear him away to the spot where the sound of the surf merged into the music of the clinking glass. While giving orders to rig out slip lines for him I heard a familiar voice on the wharf sing out "Bon voyage, bon voyage." I looked up to see the portly figure of Captain Kane. He looked as if he had slept in his clothes. His pea jacket had many wrinkles in the back and in front it was inclined to roll up toward his chin. I jumped ashore to say good-bye to this kind, if groggy old sea dog, shook him by the hand, and thanked him for my trip to the interior of the island, saying that I hoped to see him again. "You know," he said, "I am getting old, but the smell of the Stockholm tar, the white flowing sails, the squeaking blocks, the clink of the capstan, bring back memories of long ago, and, damn it all, it makes me young again." Captain Kane laid great stress on the hurricane season, as January, February and March were the months to be dreaded in the South Seas. After seeing the boulder that had been hurled by the last hurricane on these islands, I was hoping that I should be well enough to the northward, so that if one should come I would be out of the storm center, and therefore out of danger. The pilot was
  • 57. nervously pacing up and down the main deck anxious to get me away from the wharf and out to sea. Possibly a game of chess had been left unfinished. I jumped aboard and ordered the foresail and main jib set. With this done and the slip lines hauled aboard, the "Wampa" glided away from the wharf as if propelled by steam. With the aftersails spread and set to the southeast trades, and sheets trimmed to the wind, we were not long in clearing the channel reef and getting out into open water. After the pilot left I ordered the topsails set. The breeze was fair, and I was anxious to clear Bangor Island and get to the westward of it before darkness set in. The crew looked happy even after their night's debauch, some were whistling, others humming familiar ditties. Riley could be heard singing "Rolling Home Across the Sea" from his position on the foretopmast, as he changed the topsail to windward, a job which is usually done with very little sentiment of home or any other place. Distance was shutting out the tall green palms around Suva, and the town itself was just a speck on the horizon. Taking careful cross- bearings of Bangor Island, so as to avoid the dangers and submerged coral reefs that project from it, I ordered the staysails set to increase our speed so that with darkness I would be well to the westward. Our staysails were put away and stowed in the fore peak when we came into port. The second mate went forward to get them up, and Swanson went down to bend a line around them before hauling them on deck. He had been down in the fore peak only a minute before he came up the ladder running very excitedly and saying that there was a dead man lying on the staysails. The crew, much upset by this remark, slunk away from the fore peak hatch as if deadly fumes were coming from within, so I got a lantern and went down to see the supposed dead man. I was confronted by a Hindoo stowaway.
  • 58. He was so weak from the heat of the fore peak and thirst that he seemed to have little life left in him. I called up to the deck above for a couple of men to come down and give me a hand to carry him. Old Charlie and Riley cautiously felt their way down, Riley giving orders to the crew above not to stand too close to the small hatch, as it might be necessary for him to ascend with all possible speed and he did not care to have any obstruction to his flight. Old Charlie approached with his usual forebodings. The finding of the dead Hindoo, in his estimation, meant nothing less than doom and destruction to all on board. Riley was more cheerful when he found that there was little chance of physical danger from the supposed dead man. Bending the rope around him and carrying him to the mouth of the hatch, I shouted to the crew on deck to haul away very gently. We steered him up the hatch and landed him on deck without any serious bumps. The cool breeze restored him, and when we forced some water down his throat he began to show signs of life. I went aft to get a glass of Scotch whiskey, knowing that this would stimulate the heart action. After taking a teaspoonful, his moaning changed to some kind of Hindoo gibberish. This change seemed to amuse the crew. They no longer looked gloomy and down in the mouth, but seemed very willing to help him in his fight for life. As he lay there I was seized with a very inhuman and selfish impulse. The night shades of the tropical evening were becoming conspicuous in the western horizon, the run on the log showed the "Wampa" sixteen miles to the southward and westward of Suva harbor, with the southeast point of Bangor Island bearing two points on the starboard bow. Should the Hindoo stowaway come back to life, it would be necessary to tack ship and put back to Suva in order to put him ashore. U. S. alien laws are well known to sea-faring men. This stowaway had no money, no position, and all that he had in the way of clothes
  • 59. was a thin pair of pants. Should unfavorable conditions prevent my putting him ashore, I would be forced to carry him to San Francisco. Once there I knew what the immigration authorities would do to me or to the owners. More than likely I should have to pay his passage back by steamboat to the Fiji Islands. With darkness approaching it was not my intention to put back to Suva and run the risk of striking the reef at the entrance of the harbor. For these reasons, I should much prefer a sea burial for the Hindoo stowaway. While these hard and unsympathetic thoughts were passing before the visible horizon of my mind, I was nevertheless attracted by his delicate and artistic form. The long and straight black hair, the finely molded ears, the aquiline nose, the perfect profile, the well-rounded chin, the sensual mouth with its uniform white teeth were truly oriental of high caste. An unusual type for a Fijian contract laborer. I was deeply impressed with his boyish figure as he lay struggling for breath on the deck. Suddenly I was seized with an impulse of sympathy for this frail-looking creature. Grasping the bottle of Scotch I pressed it to his lips and poured some down his throat. This act caused him to strangle. After fighting for breath he opened his eyes and sat up against the hatch combings. His eyes were bright and fiery and seemed to penetrate through one like an X-ray. They took in the situation at a glance. He realized that he was out at sea. His gaze alternated from the flowing sail to the members of the crew. His eye finally rested on Swanson, he being the most brutish looking sailor of those who were standing around, and therefore the most to be feared. I spoke to the Hindoo and said, "How long have you been on board?" "Oh," said he, "I have been down there," pointing to the fore peak, "for three days." He spoke English without an accent. Then he told how he had swam off to the ship, while we were still lying at anchor, and said that he had no idea that we would have been delayed so long before putting to sea.
  • 60. I then told him that it would be impossible to carry him to the United States of America. Although weak from heat and hunger, he staggered to his feet and kissed my hand, crying, "Oh, please, Captain, take me along with you. I cannot live there under these horrible conditions, working for sixpence a day with nothing to eat but curry and rice. I will work for you, I will do anything, only take me away from here." I deeply resented my previous thought of disposing of this intelligent Hindoo. The picture this outcast made standing there trembling, with tears streaming down his boyish face, pleading as though his heart would break, was getting the best of me. Very few men of the sea can stand tears and emotion. Although hardened by years of kicks and knocks, the old-time sailor would much prefer a knock-down and drag-out to any signs of agitation. Many of the crew themselves consciously looked to windward and wiped away a rusty tear. While the Hindoo was still pleading, Swanson stepped up to me and between sobs said, "I wish you would take him along, sir, I have no one in the world to care for, and I can easily spare the forty dollars that you say will be necessary for him to enter the United States." With this offer coming from a man like Swanson, I was as much overcome as the Hindoo was, in his pleading for liberty to be taken away from the low and dirty castes of Bombay and Calcutta which furnish labor for the Fiji Islands. He thanked Swanson by gracefully bowing and said, turning to me, "I am sure you can make some use of me on your voyage home." This statement proved true, for had it not been for the stowaway, this narrative would never have been written. The Socialist cook was standing with his back up against the galley, deeply impressed with this new possibility. From the way he ran to make milk toast for the Hindoo, one would think that at last he had discovered a new clay to mold and construct and pattern after his own impressions.
  • 62. CHAPTER XXVI The Mysterious Hindoo With the Hindoo question solved and the fisherman's staysails set, Suva was lost in the distance and remained but a memory. By the time the studded diamonds in their azure setting were twinkling in all the splendor of a Southern sky, we were well to the westward of Bangor Island. We had nothing to fear from coral reefs until we neared the Gilbert group, which lay east of the 180th meridian and north and south of the Equator. After the Hindoo had eaten the milk toast and found that he was in the midst of friends, sailing away to a country where opportunity knocks on the door of hovels, he no longer looked the slave to his master. He refused to bunk in the forecastle, preferring to sleep under the forecastle head. The tropical nights were warm, and for the time being this was a comfortable part of the ship in which to sleep. The crew were kind enough to furnish blankets for him, in fact, were willing to give him anything they had, for they considered him an unusual guest. At ten o'clock I turned in and left orders with the second mate to call me at midnight. By that time I knew that if we held our present rate of eleven knots per hour, we should be far enough to the westward to change the course, and haul her more northerly. Coming on deck at eight bells and getting the distance run on the log, I went back to my room to measure the distance on the chart before changing the course. I decided to run one more hour before changing to the northward. Old Charlie was at the wheel, and it seemed from the way he was clearing his throat that he was anxious for a chat. But discipline
  • 63. forbade. I walked forward to look at the sails, and see if they needed sweating up. While looking around I ran into Riley, who as usual was smoking his clay pipe, with its black bowl and short stem. It was strong enough of nicotine to drive a wharf-rat to suicide. "Riley," said I, "no doubt you are happy that we are on the last leg of our voyage." Before answering he gave a few heavy puffs on the old dudeen to insure its not going out. While he was doing this I immediately changed for a new position to windward, for to be caught to leeward of these deadly fumes was to share the fate of the wharf-rat. "Well," said Riley, "I am, and I am not." "Come," I replied, "what is it that troubles you?" Thinking that I had found the source of his discontent, I added,—"Surely, you can't expect me to feed you on Scotch whiskey all the passage home? What little there is on board must be kept for medicine. Just think what might have happened to the poor Hindoo had I not had a little Scotch left on board." At the mention of the Hindoo's name Riley stepped up close to me, saying, "Whisht, and it is that what is troubling me, it is that damned coolie," and he pointed to the forecastle. "Surely," I protested, "you are not afraid of that poor weak creature." Riley fastened down the tin cover to his pipe so as to secure the remains of the tobacco for future use. Economy of tobacco is strictly observed on long voyages. Even the ashes have an intrinsic value among sailors, like the kindling wood of a coal stove. Tucking the pipe away in the folds of his breeches, he said: "Ho, ho, and it is afraid you would have me! Shure'n I am afraid of nothing in the say, and I will be damned if I will be afraid of anything on top of it."
  • 64. "Well, what about the Hindoo, what harm can he do to you?" "Oh, it's the divil a bit he will be doing me. It's his snaky movements and his ferret eyes that is getting on me nerves. During the dog- watch," continued Riley, "we fixed a place under the foc's'le head for the coolie, giving him what blankets we could spare. At eight o'clock our watch below turned in. Says I to Dago Joe, 'Turn down the glim.' 'I will blow it out,' says he. 'Not by a damn sight,' says I. 'Shur'n we are liable to scrape our bottom on an auld coral reef around here, and it isn't Mike Riley that is going to get caught like a rat in a trap.' The Dago is a reasonable man to talk to, and with that he turns the light very low. About eleven o'clock I woke up along the hearing Broken-Nosed Pete snoring. After throwing me auld shoe at him, I rolled over with me face to the scuttle hatch, to get meself another nap before eight bells, when I see the Hindoo standing there at the bottom of the ladder. I rubbed me eye to make sure it wasn't desayving me. Pulling meself together, I says to meself, says I, 'Whativer he is, he is there for no good purpose.' Begob, the strangest thing about the coolie was that he did not move a muscle, but stood there like a statue, staring straight into me eye. "I shouted to the Dago to turn up the light, which is within easy reach of him. Says I, 'Things are not as they should be down here.' With me eye still on the Hindoo, Dago Joe turned up the light. I declare to me Maker when the light was turned up the Hindoo had disappeared. "'That's damned strange,' says I to Dago Joe. 'Be Hivens he was standing there not a minute ago,' and when I comes up on deck at eight bells I looked under the foc's'le head and there he is, fast asleep. So I lights me poipe, and takes a look over the sea to leeward of the foresail, to see if we are still in sight of land. While I am standing there humming a bit av an auld ditty, all of a sudden I felt meself in the presence of something uncanny, and turning around quick-like, there stood the coolie. Ses I to him, ses I: "'What are you up to, me boy?'
  • 65. "'Oh,' says the coolie, 'the wash on the prow is disturbing to my peaceful slumbers. I should much prefer being crooned to sleep by the waving branches of a Himalayan evergreen.' "Ses I, 'Me coolie friend, no more of your palavering. Back to bed with you, and stay there.' I looked at him again, and, shure, Howly St. Patrick, he disappears like he did in the foc's'le." "Where is he now, Riley?" "Begobs, and I don't know, sir." I went forward to see the strange visitor who seemed to be causing Riley so much misery. There, under the forecastle head, the Hindoo lay, wrapped in his blankets, sound asleep. "Riley," said I, "you drank too much Scotch last night; be careful that you don't get the Jimmies and jump overboard. If you feel yourself slipping just tie a gasket around you. We need you to work ship on the voyage home." These insults were too much for Riley. He slunk away to the lookout where Broken-Nosed Pete would lend a willing ear to his story of the Hindoo and his abuse of me. At one o'clock, feeling sure of the reefs, I changed the course to N. N. W. The next morning the Hindoo was eating his breakfast off the forehatch and looking much better than he had on the preceding evening. He rose and thanked me kindly for the interest we had taken in him, saying: "I feel the pleasure of liberty after my prison term, among those terrible people. As for last night, I was quite comfortable. I can easily adapt myself to the new environment. But although I could not quite understand what the one-eyed man meant when he bent over me in the night, exclaiming, 'There he is, and the divil a move
  • 66. out of him,' I feel nevertheless, that I am in the midst of friends, and I shall do my best to entertain their friendship." These quaint expressions were pleasing to me, and I continued the conversation. He said that he had had no sea experience. That while going from Bombay to the Fiji Islands he was battened down in the hold with the rest of the coolie labor, and only allowed to walk the deck a short time in the evenings. He was anxious to work and help in any way that he could. The second mate put him to work scrubbing paint-work. There is always plenty of this kind of work to be done on every ship. The Hindoo went to work with a will, as if glad to have the opportunity. For the next four days the southeast trades held fair, until we were well to the northward of the Fiji group. I was hoping to get east of the 180th meridian before crossing the Equator, This would give me a better slant before I struck the northeast trades. Then in latitude about 30° north we would encounter the westerly winds, which would be fair for the Pacific coast. I was well pleased with the progress we had made since we left Suva, and I anticipated making a sailing record from the Fijis to San Francisco. Events had favored us since our departure. The crew were willing and the good ship herself seemed to feel that she was homeward bound. But our outward peace was somewhat broken by the sudden and mysterious illness of the Hindoo, who, after the second day out from Suva refused to eat, complaining of a headache, and later remaining for hours in what appeared to be almost a state of coma. I was worried by this new disease, and hoped that it would not prove to be contagious. As a precautionary measure, I removed the Hindoo aft to the deceased Captain's cabin. For two days it was with a great effort that he was even aroused to drink a cup of bouillon.
  • 68. CHAPTER XXVII The Hurricane At two o'clock in the morning of our fifth day from Suva, I was awakened by hearing the booms and gaffs swinging as if in a calm. I thought this very strange, as the southeast trades should have held until we were well across the Equator. Rushing up on deck, I was indeed surprised to find the sails hanging in midships, and not a breath from any quarter of the compass. I ordered the staysails down and the topsails clewed up and made fast, also the flying-jib and outer jib. (These lighter sails in a calm usually flop to pieces, especially where there is a rolling swell.) Away to the eastward I noticed a heavy bank of clouds, but considered this of minor importance, as we were nearing the Equator. It usually means heavy rain, but seldom wind. Yet this morning there was something out of the ordinary, because of the long swell coming from the northeast, and the sickly and suffocating atmosphere. The unusual stillness was intensified by the murmuring and talking of the crew. The men who were making fast the headsails on the flying jibboom could be heard plainly from the poop deck, growling and swearing as they passed the gaskets around the sails. Such was the funereal quietness of the morning that even the stars were hidden in halos of a yellowish color. Giving instructions to haul in the log line, I went below to look at the barometer. I was surprised to find it falling. I next consulted a Pacific directory, and found that these unusual conditions preceded a hurricane. This information upset me greatly. I had never experienced a hurricane, but well knew that their force and destructive power was very great.
  • 69. Before going on deck again, I looked in on the Hindoo in the Captain's room. As usual, he was in a stupor, and looked as if he had not moved since being fed the preceding evening. I did notice from the heaving of the skeleton-like breast, that the breathing was regular, and not intermittent as it had been on the preceding evening. On deck, I had all the reef-earrings brought up from the lazarette, and got everything in readiness for any emergency. I was well to the westward of the Gilbert group, but still to the eastward of the 180th Meridian. Should the hurricane come out of the east, I could heave to and ride it out without any danger of fetching up on one of the Gilbert Islands. In the cabin the barometer was falling so fast that it now showed hurricane weather. I knew that it was only a question of a few hours before we should feel its fury. My experience was limited in the laws of storms. If we were in the storm center it would be necessary to put her into the port tack. By doing this I should be forced south, and back onto the northern isles of the Fiji group, while on a starboard tack I should be driven onto a lee shore of the Gilbert Islands. Either course meant destruction. With daylight and hot coffee this gloomy situation assumed a more cheerful aspect. While the old sailor has the light of day to guide him over storm-tossed decks, he becomes more tolerant of ship and crew. At half-past five the white caps could be seen coming from the northeast, and before we got the spanker down the gale struck us, about six points on the starboard bow. The old ship reeled to leeward, with the lee rail under water. The decks were almost perpendicular. It seemed that no power on earth could right her to an even keel again. There were two men at the wheel, trying to keep her off before the gale, but it was of no avail, for she refused
  • 70. to answer her helm, and lay throbbing as if undecided whether to seek a watery grave, or to continue her fight for victory. Swanson, by a heroic effort, cut the fore and main sheet, and then let go by the run. The tense situation was relieved as the booms flew seaward over the lee rail. We then kept her off before the gale with the wind on the starboard quarter, immediately setting to work to reef the fore and main sail. By nine o'clock, three hours and a half later, it was no longer a gale, but a hurricane. With three reefs in the foresail and a goose-wing spanker, we ran before it. It was too late to heave to. With such a tremendous sea running it would mean destruction to ship and crew to try the latter move. As it was, the ship was awash fore and aft from seas breaking over her. Should the hurricane hold out for ten or twelve hours more with our present rate of speed we should be dashed to pieces against one of the Gilbert group. At four bells the velocity of the hurricane was so great that one was in danger of being blown off the schooner. We rigged life-lines on the fore and main decks, also on the poop deck, and by their help the crew managed to keep from being washed or blown overboard. The sea looked like an immense waterfall, one enormous roaring mass of foam. Occasionally from out of this terrible cataract a Himalayan sea would gain in momentum and dash itself against our starboard quarter, submerging the vessel. At such times all that would be identifiable of the "Wampa" would be her rocking spiral masts. Like a struggling giant she would raise her noble head and shake herself clear of this octopus, shivering, but never spent. About noon the hurricane jumped suddenly from the northeast to east southeast, without losing any of its velocity. In order to keep running before it, and keep the wind on our starboard quarter we hauled more to the northward and westward, although to do this it was necessary to drive into a beam sea, which made it all the more
  • 71. dangerous. Also the sea was driving from the east southeast and this formed a cross sea. When these two seas came together, the "Wampa" would rise and poise on them as if on a pivot. In this position, and with the gale blowing on the starboard quarter, her head would be thrown into the beam sea. It looked as if we could not survive. There was constant danger of our being broken up into small pieces. We dropped the peak of the spanker that formed the goose-wing sail, put it into gaskets, and ran with a three-reefed foresail. We then put the oil-bags over the stern in the hope of quieting these angry seas. But this was useless. While we were fastening the lines that held the oil-bags in the water, a crushing comber came whistling along and filled our stanch little ship again from stem to stern. When she shook herself clear of the boiling foam I noticed that our oil- bags were gone, and with them the Captain's boat which hung from davits over the stern. Old Charlie and Dago Joe were steering. Old Charlie had a faraway look in his watery eyes as he spoke and said: "I am afraid, sir, this will be my last trick at this wheel." I spoke harshly to this old sailor, saying, "To Hell with sentiment, this is no place for it. Watch your steering and don't feel sorry for yourself." Had I known what was so soon to happen I should not have so upbraided this poor harmless old soul. I have often regretted it. Riley, who was taking no chances, was seemingly not all handicapped by his one eye. Always alert and as agile as a tiger, he went about the decks as if nothing were out of the ordinary, although to hear him talking to himself one would think that he expected to be extinguished by every sea that came. He had about twenty feet of manila rope tied about his waist with the end held in his hand. When a sea would hit us Riley would see it coming, and
  • 72. would pass the rope end around a belaying-pin or anything that he thought would hold his weight. It was while she cleared herself from the sea that carried away the Captain's boat that I found Riley twisted around the spanker sheet like an eel. It took him some time to extricate himself, always watching the progress of the stern sea, and not seeming to notice his number ten brogans, which had woven themselves into the spanker-sheet falls. The hurricane was raising havoc with Riley's mustache. Having blown all over his face, it looked as if the only way to quiet it would be to put it into a plaster of Paris cast. He finally pulled himself clear of the sheet, exclaiming: "Be Hivins, and wasn't that a close call—" Just then Swanson came running aft and reported that the martingale guy had carried away on the flying-jibboom. It was then that my heart sank within me. I knew what to expect. Dismantled,— then to perish at sea!
  • 73. CHAPTER XXVIII The Master Returns The thought of our dead captain came to me, of what his will would have been in this crisis of life and death, and I paused to wonder why he had not rested until he was assured that I would not carry his precious treasures back with me. Did he expect this situation, and doubt my ability to cope with it? Action followed thought, and I ordered the second mate and the crew forward to see what could be done with the martingale guy. Still the humor of the moment appealed to me. As Riley left the poop he shouted, "Be the Holy St. Patrick, it has blown the buttons off me oilskin coat." There was no question about its blowing, but it was also possible that his snakelike position on the spanker-sheet had something to do with the lost buttons. It was now past noon. None of the crew cared to eat, preferring the wave-swept deck to anything the cook had to offer. The murderer who pays for his crime on the gallows and enjoys his ham and eggs on the morn of execution may be happy indeed, but this does not apply to the sailor. When there is a life and death battle on with the elements, he is there to grab the one last chance if there be one. If not, he prefers a watery grave to claim him with his stomach empty. The seas kept coming larger, and every time one would break and spend itself on the decks I thought it would be the last, and that she could not arise. But she shook herself clear as she climbed the waves; then again the sea, and again the dread. I could not leave the poop nor the two men at the wheel. A wrong turn at this howling, raging time, would mean quick despatch to the
  • 74. land of no awakening. Sometimes even the helmsmen grew afraid, but a word of encouragement sufficed to quiet them. While I was standing to windward of the men at the wheel, watching her every move as she was pitched hither and thither on this crazy spiral sea, she shipped a green sea that shook her from stem to stern. It was with great difficulty that she raised her black hull to the raging storm again. I shouted to the men at the wheel. It was too late. She had broached to with the stern sea on the beam, and the beam sea right ahead. Then the beam sea submerged her, and by it I was carried across the poop deck, and found myself held under the wheel-box, with both legs pinned in a vise-like grip by the tiller, which extended forward of the rudder-head. Although dazed and strangled by the terrible impact of the water, I managed to twist the upper part of my body towards the wheel and to murmur, "For God's sake keep her off." My weakened voice was lost in the tempest. There were no ears to hear my pleadings. The men at the wheel were gone. Gone, indeed, to a watery grave, and perhaps the others also. With me it would not take long. Just another raking like the last one, and then the finish. Again the cook's words echoed louder than the raging storm, "Do we finish here?" As I lay there pinned to the deck, too helpless to even call aloud, and as it seemed waiting, waiting, for the executioner to spring the deadly trap, I was conscious that the door of the companion-way had closed with a bang so terrific that it sounded above the storm. I twisted my head and shoulders around to see if I dared to hope. There before me stood the Hindoo stowaway. He did not notice me lying there pinned under the wheel-box, nor could I manage to attract his attention. With opal eyes glowing green and fiery red, he sprang to the wheel, and with magnificent strength pulled on the spokes till they
  • 75. screeched louder than the storm as they were dislodged from their oxidized fittings. Harder and harder he pulled on the wheel. He didn't even notice the seas breaking over him. The mysterious thing about him was that he seemed to know what he was doing. He was keeping her off before it. In doing this he removed the tiller from my legs. At last I was free. As I struggled and crawled to the weather-rail for support, the Hindoo shouted in clear and ringing tones, in true seamanlike fashion, looking neither to the right nor left, but straight ahead, as if staring into a land-locked harbor. He repeated his order for the second time in a high tenor voice: "Get an axe out of the donkey-room and cut away the lee martingale guy. Your flying-jibboom is gone overboard and is still held by the lee guy. It is plowing a hole in the port bow." I knew but one law. The law of self-preservation. My arms were locked tight around the stanchion that supported the weather-rail. That quick command of the Hindoo brought me sharply to the realization that I was not yet given that quick despatch to the land of nowhere, but was still in the flesh, and very much alive. My first rational thought was, "What in Hell is the Hindoo doing at the wheel?" My pride as a sailor resented the affront put upon my ability as a sailor by a stowaway who was daring to assume the command of my ship, and daring to issue orders to me. Letting go my hold on the stanchion, I cautiously made for the Hindoo helmsman. While in the act, she shipped another drencher. I was carried off my feet and washed away to the lee scuppers. But I managed, by some interposition of Divine Providence, to fasten my arms around the mooring-bitt, thus saving myself from an angry and cruel sea, which seemed to delight in playing with me as a cat does with a mouse, only to swallow me up in its fathomless depths. Once again she wrenched herself free of the mad swirl and her stern went down until we were in a valley between mountains of water. I
  • 76. realized as I looked up at the bows which seemed to be towering above me, that the flying-jibboom, like a clipped wing, was missing. Like a flash I wondered how the Hindoo knew that the jibboom was gone. As her stern ascended high into the air, I jumped for the wheel and with an exclamation of joy I shouted, "God in Heaven, the Captain!" There he stood beside the Hindoo. The dead Captain. The same heavy mustache covered the lower lip. The same fiery eyes that knew no defeat. He was looking straight ahead with muscle-set jaws. He appeared as if in the flesh and ready as of yore to battle with the elements. Then, like a flash, he vanished, and the Hindoo stood alone, pulling and tugging on the wheel with his supple arms. He spoke, and his usually high-pitched tenor voice rang out piercingly clear. "Cut away your jibboom, you have no time to lose. Have no fear." I knew that her former Captain was in command of the ship, and that his masterly seamanship wrought through the Hindoo. I crept forward with new courage to do his bidding. Huddled together beneath the forecastle-head stood what remained of the crew, who seemed not to know that two of their number were gone. The second mate was praying, and helpless from fear to be of any use in handling the schooner. Riley had his three-inch sailor's rope fast to the windlass with one extra turn around his body. He was taking no chances. Swanson was the only one without fear. When I called for a volunteer to cut away the flying jibboom he made for the axe and rushed onto the sea-swept forecastle-head. As the schooner arose high in the air, he swung over the lee bow and with one stroke of the axe cut away the hemp lanyard that was holding the massive spar from its freedom.
  • 77. Welcome to our website – 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