Developing and Deploying Java Applications for BlackBerry - PowerPoint PPT Presentation

About This Presentation
Title:

Developing and Deploying Java Applications for BlackBerry

Description:

... using the Java Community Process (JCP) using formal Java ... For more info, see http://www.jcp.org. The BlackBerry Perspective. BlackBerry and J2ME ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 34
Provided by: edk88
Category:

less

Transcript and Presenter's Notes

Title: Developing and Deploying Java Applications for BlackBerry


1
Developing and Deploying Java Applications for
BlackBerry
  • Making Sense of it All

Eric GiguèreSenior Software Architectgiguere_at_ian
ywhere.com
2
Overview
  • Understanding J2ME in general
  • The BlackBerry perspective on J2ME
  • Gathering the necessary pieces
  • Programming tips
  • Moving beyond the BlackBerry

3
About iAnywhere
  • iAnywhere is the acknowledged leader in mobile
    databases, mobile middleware, and mobile
    management

4
About Eric
  • Practicing software developer, extensive
    experience with mobile platforms and with all
    kinds of Java-based technology
  • Author of three books, including the first book
    on Java 2 Micro Edition -- over 5 years of J2ME!

Dont buy these, theyre way out of date!
5
A Question
  • Q Why did the chicken cross the road?
  • A She was too busy browsing her AvantGo channels
    on her BlackBerry.
  • Point your BlackBerry Browser
    torim.avantgo.com

6
At the Sybase Booth
  • Visit the Sybase booth in the Solutions Showcase
    for a demonstration of the new MobiLink Client
    API
  • Sync relational data down to the device and back
  • SQL Server, Oracle, DB/2, ASE, SQL Anywhere
  • Ask for Liam
  • Or talk to me after the session (my code)

7
Understanding J2ME
8
Understanding J2ME
  • Java 2 Micro Edition (J2ME) is an umbrella term
    for a set of Java technologies created to run
    Java on less capable devices
  • Key concepts of configurations, profiles and
    optional packages
  • configuration VM runtime classes
    (horizontal)
  • profile domain-specific classes for building
    standalone applications (vertical)
  • optional package domain-specific classes that
    expose specific functionality but not
    applications (horizontal or vertical)

9
Configurations
  • Only two configurations defined
  • Connected Limited Device Configuration (CLDC)
  • Connected Device Configuration (CDC)
  • CLDC is a stripped-down VM and runtime
    environment
  • no finalization, no reflection, only a few
    classes
  • CLDC 1.0 didnt even support floating-point
  • CDC is a superset of CLDC
  • full language and VM support
  • a much broader set of standard Java 1.3 classes

10
Profiles
  • Profiles built on the CLDC
  • Mobile Information Device Profile (MIDP)
  • Information Module Profile (IMP)
  • Headless MIDP (no UI)
  • Profiles built on the CDC
  • Foundation Profile
  • Personal Basis Profile
  • Built on top of Foundation Profile
  • Personal Profile
  • Build on top of Personal Basis Profile
  • The transition profile for the old PersonalJava

11
Optional Packages
  • Many released or in development, some examples
  • PIM Optional Package
  • File Connection Optional Package
  • Wireless Messaging API
  • Mobile Media API
  • Problem not every device supports every optional
    package

12
Who Does All Of This?
  • All J2ME standards are developed using the Java
    Community Process (JCP) using formal Java
    Specification Requests (JSRs)
  • JSRs developed by an expert group (EG)
    representing the J2ME community at large
  • RIM is on the EGs for several of the important
    standards
  • For more info, see http//www.jcp.org

13
The BlackBerry Perspective
14
BlackBerry and J2ME
  • BlackBerry devices (Java-based) run MIDP and
    CLDC
  • MIDP 1.0/CLDC 1.0 for 3.6/3.7 devices
  • MIDP 2.0/CLDC 1.1 for 3.8/4.0 devices
  • Custom Java VM
  • Additional APIs available
  • Some optional packages
  • Many BlackBerry-specific APIs (vendor
    extensions)
  • Built-in apps written in Java
  • RIM eats its own food

15
Application Models
  • MIDlets
  • Applications built using MIDP application
    lifecycle and user interface classes
  • Portable to other platforms unless BB APIs used
  • BlackBerry applications
  • Standard public static void main( String args
    ) entry point
  • Tied to BlackBerry, but more control over the
    application
  • BlackBerry-specific UI classes
  • Can run in background (no UI), on startup, etc.

16
How Applications Are Built
  • Classes are compiled as usual
  • CLDC requires a separate preverification step
  • Output then transformed using RIM tools into a
    .COD file that can be installed on the device
  • Applications can be loaded directly through
    BlackBerry Desktop Manager, the javaloader tool,
    or wirelessly via over-the-air (OTA) provisioning

17
How Applications Are Built
  • Standard tool is the Java Development Environment
    (JDE)
  • integrated editor, debugger
  • Can also use Ant with Antenna tasks
  • See http//antenna.sourceforge.net
  • Eclipse also possible using AntAntenna
  • Getting the classpaths right can be tricky
  • See http//eclipseme.org for the EclipseME project

18
BlackBerry APIs
  • Rich set of BlackBerry-specific classes
  • Utility classes to deal with missing J2SE
    classes
  • Different UI model than MIDP
  • Encryption classes
  • A persistent object model loosely patterned on
    Java serialization
  • More communication protocols, not just HTTP
  • Many APIs require your app to be signed

19
Gotchas
  • Occasionally classes are documented but not
    implemented until someone pesters RIM
  • Only documentation is from RIM
  • Javadocs needs some work, lacking many details
  • The only BlackBerry books available so far are
    about using the device or making blackberry
    wine.
  • But at least one BlackBerry programming book is
    coming
  • Pester RIM for better docs and tool enhancements!

20
Gathering the Necessary Pieces
21
Getting Started
  • Download the JDE from http//www.blackberry.com
  • Versions for 3.7 or 4.0
  • If youre going to target 3.6 or 3.7, use JDE
    3.7
  • Youll also need Java SDK 1.4.2
  • http//java.sun.com/j2se/1.4.2/download.html
  • New to Java? Find some old books
  • Ideally covering Java 1.1, not 1.2 or higher
  • You wont get seduced by all the new classes,
    especially new 1.5 features like generics and
    enums
  • But important concepts like inner classes are
    covered

22
Do You Need a BES?
  • RIM ISV partners can purchase a BES for
    development purposes
  • useful for testing apps
  • can enable things that corporate BES disallows
  • and for understanding how things are done
  • IT may raise concerns
  • not that easy to setup
  • dont forget a mail server is required
  • Exchange needs its own NT domain

23
Code Signing
  • Most interesting APIs protected, app wont run
    on device without being signed
  • But you can run them in the simulator
  • Signing requires certificates obtained from RIM
  • Small fee (100) involved
  • Certificates needed for each build machine
  • Signing is an online-only process
  • Communicates back to RIM
  • Certificate owners gets email every time

24
Programming Tips
25
Reduce, Reuse, Recycle
  • Dont create lots of objects
  • Garbage collection eats up CPU time
  • Can run out of object handles
  • Look for opportunities to reuse objects
  • Invariant classes good in theory, but more
    realistic to allow changes
  • Remember arrays are objects!

26
Use Threads
  • Always do I/O operations on an application-defined
    thread
  • Dont block the system event thread
  • Not only slows things down, but may also cause
    the app to freeze as system tries to prompt user
    for permission
  • Java threading mechanisms are quite good
  • Take the effort to learn them
  • Good book is Concurrent Programming in Java by
    Doug Lea

27
Keep Applications Small
  • Dont go overboard with inner and nested classes
  • Think carefully about class interactions and
    dependencies
  • Can you get away with using a built-in class
    instead of your own?

28
HTTP or Sockets?
  • If youre using MDS, sockets are a great option
  • Can also open a server socket and listen for data
    to be pushed to your app
  • Extra complexity of defining your own protocol
  • For non-MDS, HTTP is the best
  • Easier to get through the firewall
  • Support varies greatly by carrier, though
  • HTTPS may also be available
  • Easy to write servlet that shares the same data
    classes (Java on both ends)

29
Start the MDS Simulator!
  • If youre doing network I/O, remember to start
    the MDS simulator before you run your app in the
    device simulator

30
Moving Beyond the BlackBerry
  • Non-BlackBerry J2ME devices becoming more
    powerful
  • Still mostly consumer-oriented
  • In the future, more will be running the
    BlackBerry environment (BlackBerry Built-In) as
    well
  • Your BlackBerry apps will work on BlackBerry
    Built-In without any changes
  • Things you take for granted in an MDS environment
    are not there
  • Have to get through the firewall
  • Not as secure

31
MIDP-Only Is One Option
  • You can write an application that only uses APIs
    from MIDP and perhaps an optional package or two
  • Application gets packaged as JAR file and an
    accompanying JAD file
  • Will run on most J2ME-enabled cellphones
  • Except that there are many buggy implementations

32
Other Option Split the Source
  • Alternatively, build two different apps, one for
    BlackBerry, one for MIDP
  • Split code into three parts
  • One common (no BlackBerry APIs, no user
    interface)
  • One for BlackBerry
  • One for MIDP
  • More complex code due to use of factories and
    more interfaces and abstract classes

33
Q A
Write a Comment
User Comments (0)
About PowerShow.com