Datasheet
24
Part I: Getting Started on BlackBerry Apps
Java programming for BlackBerry
For BlackBerry development, you should be familiar with Java programming
in general, and you should know the basics of Java syntax. BlackBerry Java
development is somewhat different from desktop PC Java development. The
major difference is BlackBerry Java has a somewhat smaller set of classes
that you can use to develop applications. Several of the basic Java packages
are available:
✓ java.io.*: This package contains the input/output classes you can use
to manage retrieving data from and delivering data to various locations,
such as Web services and data files.
✓ java.lang.*: You will find the familiar Java base classes such as
String in this package.
✓ java.util.*: Some of the classes available in the desktop version of
Java are available here, such as Vector.
Not all the classes available in the JSE version of these packages are available
in the BlackBerry version. For instance, the BlackBerry java.util.* package
consists of only a dozen or so classes and interfaces, whereas the JSE java.
util.* package comes with almost ten times as many.
RIM removed many classes because of size and performance constraints. For
instance, one of the major changes to the Java language was the addition of
generics in version 1.5, for use with collection classes such as Vector (java.
util.Vector). RIM has not implemented generics for use with BlackBerry
development in part because this feature requires a great deal of overhead
(such as OS functionality) that doesn’t provide a dramatic improvement in
the end result in terms of performance.
In addition to these standard Java packages, several of the javax and org
packages are also available:
✓ javax.microedition.*: The Java Micro Edition (JME) packages are
all available for you to use. If you’ve developed a JME application, you
can run it without modification on a BlackBerry.
✓ javax.bluetooth.*: Your application can access the Bluetooth
hardware on a BlackBerry, if it’s available.
✓ javax.xml.*, org.w3c.dom.*, org.xml.*: These packages provide
classes your app can use to read and write blocks of XML data.
RIM provides a fairly rich framework of classes and interfaces that you can
use to make your application do just about anything you need. The RIM
classes fall into the following three categories:
05_467114-ch01.indd 2405_467114-ch01.indd 24 8/30/10 1:05 PM8/30/10 1:05 PM