blackberry and java
TRANSCRIPT
-
8/8/2019 Blackberry and Java
1/21
1
Introduction to Java and J2ME
Development
Using BlackBerry Development Tols
Platform for Developing Applications
-
8/8/2019 Blackberry and Java
2/21
2
Agenda
Introduction to J2ME Overview of J2ME architecture & APIs
Toolkits for Application Development
Sample Application
J2ME: Advanced Topics Best Practices
Application Deployment
MIDP 2.0
-
8/8/2019 Blackberry and Java
3/21
3
J2ME Architecture
A standard subset of the Java (J2SE) class libraries
to enable Java applications to run on small computingdevices
Defines a Virtual Machine called the KVM Optimized for use on small devices
Recognizes that small devices vary greatly in theirnature
J2ME defines Configurations (baseline) and Profiles(application-specific)
Target Devices: Mobile phones, PDAs, Car navigationsystems, embedded devices
-
8/8/2019 Blackberry and Java
4/21
4
J2ME CLDC 1.0 Configuration
Configurations
Core set of classes that provide the minimal features that alldevices in this configuration must support
Connected Limited Device Configuration
Defines configurations for devices with: Variable network coverage
Slow processing speed
Limited memory
Target Devices: Mobile phones
Low-end PDAs
-
8/8/2019 Blackberry and Java
5/21
5
J2ME CLDC 1.0 Configuration
CLDC 1.0 provides the following Java libraries:
Library Example
HttpConnection
StreamConnection
javax.microedition.io
CLDC-specific input/output library
Vector
Random
java.util
Standard java utilities library
String, Byte
Thread
java.lang
Standard java extended language
library
InputStreamOutputStream
java.io
Standard java input/output library
-
8/8/2019 Blackberry and Java
6/21
6
J2ME MIDP 1.0 Profile
Profiles
Classes geared towards specific types of applications
(uses of a device) Mobile Information Device Profile
Built on top of CLDC 1.0, with extra APIs for: Defining and controlling applications
Displaying text and graphics
Persistent data storage Network connectivity
Applications built using MIDP/CLDC are referred to asMIDlets
MIDlets sharing code/data are referred to as MIDlet suites
-
8/8/2019 Blackberry and Java
7/217
J2ME MIDP 1.0 Profile
MIDP 1.0 provides the following Java libraries:
Library Example
RecordStorejavax.microedition.rmsRecord Management System (data
storage)
Screen, Graphics
Textbox,CommandListener
javax.microedition.lcdui
LCD user interface library
MIDletjavax.microedition.midlet MIDP application library
-
8/8/2019 Blackberry and Java
8/218
BlackBerry J2ME API Extensions
All BlackBerry Java devices support CLDC & MIDP 1.0
RIM has developed extensions to the standard J2ME libraries toenable more flexible and customized integration with BlackBerryfeatures
Developers can write new applications for BlackBerry usingthese Java APIs
Java APIs for BlackBerry enable you to develop custom clientapplications that provide:
Robust & customizable User Interface
Persistent Data Storage on the handheld
Event Listening & System interfaces
Secure wireless transport via HTTP(S) and Email
-
8/8/2019 Blackberry and Java
9/219
BlackBerry J2ME API Extensions
For more advanced applications:
Integration with BlackBerry Email & PIM
applicationsBulk data loading and backup/restore via
Desktop Manager
Always-on & Auto-started background
threads & PUSH
-
8/8/2019 Blackberry and Java
10/2110
BlackBerry J2ME API Extensions
Library Example
ResourceBundle
Locale
net.rim.device.api.i18n
Internationalization support
Array, HashTable
StringUtilities
net.rim.device.api.util
Extended utilities library
EditField, ListField
Menu
net.rim.device.api.ui.component
UI objects that reside within a container
MainScreen, FullScreen
PopupScreen
net.rim.device.api.ui.container
UI objects that contain other elements
Screen, Graphics
UiApplication
net.rim.device.api.ui
Fundamental user interface library
TrackwheelListener, KeyListener,Application
net.rim.device.api.system
BlackBerry system-level library
-
8/8/2019 Blackberry and Java
11/2111
J2ME Architecture for BlackBerry
BlackBerry Handheld (Radio, LCD, RAM, Keyboard etc.)
Java Virtual Machine
J2ME APIs(MIDP & CLDC)
APIs for BlackBerry
(UI, System, compression,
etc.)
Java Applications
-
8/8/2019 Blackberry and Java
12/2112
J2ME Wireless Toolkit
Supports development of MIDP/CLDC applications
Includes an environment that allows for compilation,execution and packaging of applications
Can be integrated with a compatible IDE (eg. SunONE Studio Mobile Edition) that allows for debuggingand editing source code and emulation
J2ME Wireless Toolkit 2.0 supports MIDP 2.0applications
-
8/8/2019 Blackberry and Java
13/2113
BlackBerry JDE
Custom client applications are built with theBlackBerry Java Development Environment (JDE)
BlackBerry JDE v3.7
Based on Java 2, Micro Edition (J2ME): MIDP/CLDC 1.0
Full featured Integrated Development Environment (IDE)with Handheld Simulators, MDS Simulator, Debugging &Optimization tools
Robust Java API set
BlackBerry JDE v4.0 Release date: September 2004
MIDP 2.0 and CLDC 1.1 support
Enhanced BlackBerry APIs
-
8/8/2019 Blackberry and Java
14/2114
Sample Application
1. Launch Application 2. List of Customers 3. Create New Call Report 4. Enter Details & Submit
BlackBerry
Server
Web/App
Server
Data Store
-
8/8/2019 Blackberry and Java
15/2115
Sample Application
Data StoreWeb/App
Server
HTTP
http://myWebServer/bb/callReport
1. Launch Application 2. List of Customers 3. Create New Call Report 4. Enter Details & Submit
BlackBerry
Server
-
8/8/2019 Blackberry and Java
16/2116
Sample Application
Data Store
HTTP Interface
(Receive Data)
Connector Interface
(ODBC, J2EE, .NET)
App Logic &
User
Management
J2EE/.NET
ODBC/SQL
Web/App
Server
HTTP
http://myWebServer/bb/callReport
1. Launch Application 2. List of Customers 3. Create New Call Report 4. Enter Details & Submit
BlackBerry
Server
-
8/8/2019 Blackberry and Java
17/2117
J2ME Best Practices
Use Device Resources WiselyPlan Ahead!!
Minimize application size Limit the number of features
Object design create single objects for common tasks and reuse them
Place resource data on the server Large resources that each user will only require a subset of
Minimize run-time memory use Use scalar types (int, boolean) instead of objects (String, Integer)
Dont depend entirely on the garbage collector
Avoid creating a lot of objects quickly
Reuse objects Move computation to server
Perform data filtering, sorting, etc. on the server before sending it to thedevice
Completely process and manipulate data as needed before indicating to theuser that new data has arrived. This hides latency from user
-
8/8/2019 Blackberry and Java
18/2118
J2ME Best Practices
Code with Performance in Mind Use local variables
Generally quicker to access local variables than class members
Use threads for lengthy operations ( > than 1/10 second) Stop the operation from blocking the main UI thread
Set appropriate access and declaration type Declare members as privatewhenever possible
Declare classes as finalif they will not be extended
Carefully use staticand final understand the performance impacton both classand primitivetypes
Carefully optimize loops and mathematical operations
See the JDE Developer Guide for more performance tips
-
8/8/2019 Blackberry and Java
19/2119
J2ME Application Deployment
MIDlets are packaged into a JAR file
On BlackBerry, JAR files are converted to CODfiles
JAR file includes: Manifest
Java classes
Resource files
JAD file accompanies JAR Contains description (attributes) about MIDlet
Allows application manager to verify the MIDlet issuited for device before downloading
-
8/8/2019 Blackberry and Java
20/2120
JAD File Example
MIDlet-Name: CallReporter
MIDlet-Version:1.0.0
MIDlet-Vendor: RIM
MIDlet-Description: Custom CRM Application
MIDlet-Jar-Size: 15289
MIDlet-Jar-URL: www.blackberry.com/download/CRM
-
8/8/2019 Blackberry and Java
21/21
21
Questions?