java me clients
Download
Skip this Video
Download Presentation
Java ME Clients

Loading in 2 Seconds...

play fullscreen
1 / 43

Java ME Clients - PowerPoint PPT Presentation


  • 318 Views
  • Uploaded on

Java ME Clients. Mobile Computing. Some materials from MobEdu.net. Constantly changing market means focus on learning basics. PDAs are gone and mobiles change. http://www.sheldoncomics.com/archive/050222.html. Mobile computing offers a new novel dimension.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Java ME Clients' - Melvin


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
java me clients

Java ME Clients

Mobile Computing

Bruce Scharlau, University of Aberdeen, 2010

Some materials from MobEdu.net

constantly changing market means focus on learning basics
Constantly changing market means focus on learning basics

PDAs are gone and mobiles change

Bruce Scharlau, University of Aberdeen, 2010

http://www.sheldoncomics.com/archive/050222.html

mobile computing offers a new novel dimension
Mobile computing offers a new novel dimension

This is still a new programming dimension compared to desktop and conventional distributed computing.

Bruce Scharlau, University of Aberdeen, 2010

java family
Java Family

Source: http://java.sun.com/developer/onlineTraining/webcasts/pdf/toronto/bday.pdf

Bruce Scharlau, University of Aberdeen, 2010

j2me and j2ee connect easily
J2ME and J2EE connect easily

Source: http://java.sun.com/blueprints/earlyaccess/wireless/designing/designing.pdf

Bruce Scharlau, University of Aberdeen, 2010

java me components
Java ME Components
  • Hosting OS
  • KVM – execution engine with simplified JVM
  • CLDC – base library
  • MIDP – additional libraries

Phone

PDA

MIPD

Profile

CLDC

Configuration

KVM

Bruce Scharlau, University of Aberdeen, 2010

configurations
Configurations
  • CLDC – Connected, limited device configuration – assume disconnection
  • CDC = Connected device configuration – assume always connected

Bruce Scharlau, University of Aberdeen, 2010

example java me stack
Example Java ME Stack

Source: http://java.sun.com/developer/onlineTraining/webcasts/pdf/toronto/bday.pdf

Bruce Scharlau, University of Aberdeen, 2010

cldc 1 0 overview
CLDC 1.0 Overview
  • Targeted to small devices with
    • 160-512kb memory available for Java
    • Limited (battery) power and intermittent connectivity plus a small UI (screen)
  • Sun Java reference implementation using KVM

Bruce Scharlau, University of Aberdeen, 2010

cldc scope differs from core java
CLDC Scope differs from core Java
  • Main differences:
      • No floating point support required
      • No finalisation of object instances
      • Limited error handling
      • No thread groups, reflection, JNI
  • Core java.* libraries
  • I/O and networking
  • Security and Internationalisation
  • New classes, javax.microedition.*

Bruce Scharlau, University of Aberdeen, 2010

extra apis can enhance applications
‘extra’ APIs can enhance applications

Just remember that they are ‘optional’, so may not be available

Bruce Scharlau, University of Aberdeen, 2010

http://java.sun.com/javame/overview/products.jsp

cldc classes need pre verification
CLDC Classes need pre-verification

Source: http://java.sun.com/developer/onlineTraining/webcasts/pdf/toronto/bday.pdf

Bruce Scharlau, University of Aberdeen, 2010

cldc networking is based on gcf
CLDC Networking is based on GCF
  • CLDC uses GCF (Generic Connection Framework)
    • Everything is a URL

Connector.open(“<protocol>://<address>:<parameters>”)

    • Protocols supported
      • Filesk, HTTP, Sockets, Communication ports
      • All specified in MIDP Profile

HTTP and HTTPS must be supported, the others are optional

Bruce Scharlau, University of Aberdeen, 2010

mobile information device profile midp
Mobile Information Device Profile (MIDP)
  • Targets two-way devices implementing CLDC
  • Provides
    • Application model, ie lifecycle and packaging
    • Display toolkit, UI methods
    • Persistent data storage
    • HTTP 1.1 networking using CLDC GCF
    • MIDP 1.0 widely available
    • MIDP 2.0 released Nov. 2002
    • MIDP 2.1 released summer 2006
    • MIDP 3 out in beta spring 2009

Bruce Scharlau, University of Aberdeen, 2010

midp applications midlets move from state to state implementing three methods
MIDP applications (MIDlets) move from state to state implementing three methods

Bruce Scharlau, University of Aberdeen, 2010

midlets are packaged in jars with required resources
Midlets are packaged in jars with required resources

MyApp.jar

Com/package/classes

META-INF/MANIFEST.MF

Mylogo.png

MyApp.jad

Bruce Scharlau, University of Aberdeen, 2010

jad and manifest are similar required files for java me apps
Jad and Manifest are similar required files for Java ME apps

AuctionMidlet.jad

MIDlet-1: AuctionMIDlet,,com.auction.j2me.AuctionMIDlet

MIDlet-Jar-URL: AuctionMidlet.jar

MIDlet-Name: AuctionMidlet Midlet Suite

MIDlet-Vendor: Midlet Suite Vendor

MIDlet-Version: 1.0.0

MicroEdition-Configuration: CLDC-1.1

MicroEdition-Profile: MIDP-2.1

MIDlet-Jar-Size: 4396

Bruce Scharlau, University of Aberdeen, 2010

manifest goes in the jar file
Manifest goes in the jar file

MANIFEST.MF

Manifest-Version: 1.0

MicroEdition-Configuration: CLDC-1.1

MIDlet-Name: AuctionMidlet Midlet Suite

Ant-Version: Apache Ant 1.6.3

Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.)

MIDlet-Vendor: Midlet Suite Vendor

MIDlet-1: AuctionMIDlet,,com.auction.j2me.AuctionMIDlet

MIDlet-Version: 1.0.0

MicroEdition-Profile: MIDP-2.1

Bruce Scharlau, University of Aberdeen, 2010

the jad references the jar
The JAD references the JAR

Download of JAD means opening:

  • The AMS downloads the JAR by the information in the JAD
  • Mostly the JAR and the JAD are in similar folder

AMS =Application Management System

Bruce Scharlau, University of Aberdeen, 2010

the jad is validated by the ams application management system
The JAD is validated by the AMS(Application Management System)
  • Is the CLDC version correct?
  • Is the MIDP version correct?
  • Is there enough memory to download the MIDlet?
  • Where is the JAR file?
  • Where is the execution unit inside the JAR?

Bruce Scharlau, University of Aberdeen, 2010

jad used for over the air ota installation
JAD used for over the air (OTA) installation

JAD checks that the app will comply and fit on the mobile device when using OTA

Otherwise, you can install the Jar file if side-loading from PC

Bruce Scharlau, University of Aberdeen, 2010

midlet development
MIDlet Development
  • Write Java application
  • Compile
  • Preverify (and obfuscate)
  • Package into Jar file
  • Create deployment descriptor (jad)
  • Deploy and run in toolkit or other device

Bruce Scharlau, University of Aberdeen, 2010

preverify to check that classes are correct
Preverify to check that classes are correct
  • All classes automatically preverified after code is compiled
  • If it fails, then error message is passed back to the console
  • Automatically packages app using name of application directory

Bruce Scharlau, University of Aberdeen, 2010

obfuscate to shrink the application
Obfuscate to shrink the application

Renames methods and variables with shorter names

Optional and recommended

Bruce Scharlau, University of Aberdeen, 2010

jar and run in emulator
Jar and run in emulator

Create bundle with resources for deployment

Use basic or complex emulator

Bruce Scharlau, University of Aberdeen, 2010

run on device for final check
Run on device for final check

Running on real devices is the final check

Start with low end device

Bruce Scharlau, University of Aberdeen, 2010

midlet must implement three methods
MIDlet must implement three methods:

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

public class HelloMidlet extends MIDlet {

public void startApp() {

}

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

}

}

Bruce Scharlau, University of Aberdeen, 2010

midlet needs other key parts
MIDlet needs other key parts
  • Import the packages

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

  • All MIDlet extends from the MIDlet class

public class HelloMidlet extends MIDlet implements CommandListener {

  • Furthermore it implements the CommandListener class

Bruce Scharlau, University of Aberdeen, 2010

midlet needs to initialise and create variables
MIDlet needs to initialise and create variables

// Initializethe variables

private Form form;

private Display display;

private Command exitCommand;

Bruce Scharlau, University of Aberdeen, 2010

midlet use startapp to move to active state
MIDlet use startApp() to move to active state
  • The MIDlet starts at the call of the startApp()

public void startApp() {

form = new Form("Hello");

display = Display.getDisplay(this);

exitCommand = new Command("Exit", Command.SCREEN, 1);

form.addCommand(exitCommand);

form.setCommandListener((CommandListener)this);

form.append(new StringItem("Hello", "Hello World!"));

display.setCurrent(form);

}

  • Commands and the StringItem is added to the Form
  • Show the Form on the display

Bruce Scharlau, University of Aberdeen, 2010

the commandaction method handles the incoming commands
The commandAction() method handles the incoming commands

public void commandAction(Command command, Displayable screen) {

if ( command == exitCommand ) {

destroyApp(true);

notifyDestroyed();

}

}

Bruce Scharlau, University of Aberdeen, 2010

if it s not used leave it empty
If it’s not used leave it empty

The following methods are unused, so we leave them empty

public void pauseApp() {

}

public void destroyApp(boolean unconditional) {

}

Bruce Scharlau, University of Aberdeen, 2010

before and after start
Before and after start

Bruce Scharlau, University of Aberdeen, 2010

three levels of software for mobiles
Three levels of software for mobiles
  • Application level is about apps for end users using provided lower-level components
  • Middleware of communication and other libraries for protocols (bluetooth, etc)
  • Low-level software such as kernels and device drivers (platform)

Bruce Scharlau, University of Aberdeen, 2010

understanding the virtual machine aids development

Class

area

Heap

Stack

App area

Run-time

data

Understanding the virtual machine aids development

loads

Execution

engine

Class

loader

calls

*.class

Scheduler

loads classes into

Garbage

collection

Memory

manager

Bytecode

interpreter

use

Bruce Scharlau, University of Aberdeen, 2010

allow garbage collection to do its job
Allow garbage collection to do its job
  • Release early, allocate late:
  • Deallocate objects as soon as possible, and allocate new objects as late as possible

Bruce Scharlau, University of Aberdeen, 2010

pay attention to your memory usage to improve performance
Pay attention to your memory usage to improve performance

Use what is required for the application.

Use single-linked list, instead of double if you only need to traverse it in one direction.

Bruce Scharlau, University of Aberdeen, 2010

use linear data structures to conserve memory
Use linear data structures to conserve memory

Linear data structures use adjacent memory for their components, instead of separate memory for each item.

Linear: linked lists, tables

Non-linear: graphs, trees

Bruce Scharlau, University of Aberdeen, 2010

avoid small classes in favour of larger ones
Avoid small classes in favour of larger ones

There is a basic overhead for ANY class

Inner classes cause the same problem, as does using lots of separate exceptions

Bruce Scharlau, University of Aberdeen, 2010

avoid dependencies where possible
Avoid dependencies where possible

Save items from joining the constant pool of the application’s memory load

Look to reuse classes already loaded, or use indirection (abstraction)

Bruce Scharlau, University of Aberdeen, 2010

use arrays instead of vectors where possible
Use Arrays instead of Vectors where possible

Method Allocated bytes Allocated objects

arrayImplementation 8016 1

vectorImplementation 40,000 2002

vectorImplSimple 52,000 2010

Bruce Scharlau, University of Aberdeen, 2010

use stringbuffer instead of string
Use StringBuffer instead of String

Method Allocated bytes Allocated objects

useString 39,000 450

useStringBuffer 304 5

Bruce Scharlau, University of Aberdeen, 2010

summary
Summary

Use memory responsibly for best performance

Create clients using appropriate CLDC and MIDP libraries

Bruce Scharlau, University of Aberdeen, 2010

ad