java me

Upload: stafink

Post on 08-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Java ME

    1/27

    Java ME

    Introduction

  • 8/7/2019 Java ME

    2/27

    Java Editions

  • 8/7/2019 Java ME

    3/27

    Differences J2SE / Java ME (MIDP)

    Java ME is mainly a subset of J2SE

    But different UI-and event handling functionality

    Less utility classes (only Vector and Hashtable, noLinkedLists, )

    Code runs on both platforms?

    general algorithms: yes

    But the whole application needs porting

  • 8/7/2019 Java ME

    4/27

    Java ME Core Concepts

  • 8/7/2019 Java ME

    5/27

    Configuration

    Defines Java Platform for different device

    classes:

    A configuration specifies the minimum set offeatures and Java class libraries that the

    associated Java virtual machine (JVM)

    should support.

    J2ME offers two configurations Connected Limited Device Configuration (CLDC)

    Connected Device Configuration (CDC).

  • 8/7/2019 Java ME

    6/27

    Configuration

    CLDC Limited user interface

    Low computing power (usually with a battery)

    Network with low bandwidth

    CDC

    Network connection with high bandwidth,possibly persistent

    Larger memory requirements

  • 8/7/2019 Java ME

    7/27

    CLDC CLDC is the J2ME configuration for

    devices with less than 512 KB memory

    footprint.

    CLDC is for the kilo VM (KVM), which is

    a highly optimized JVM meant for lower-

    end, network-connected, battery-operateddevices based on 16-bit or 32-bit

    microprocessors.

  • 8/7/2019 Java ME

    8/27

    CDC This configuration targets larger devices with

    more capacity and with a network-connection,

    like high-end personal digital assistants, andset-top boxes.

    On the CDC configuration there are three different

    defined profiles:

    The Foundation Profile (JSR 219) The Personal Basis Profile (JSR 217) and

    The Personal Profile (JSR 216)

  • 8/7/2019 Java ME

    9/27

    J2SE-CDC-CLDC

  • 8/7/2019 Java ME

    10/27

    Profiles

    Extension and more detailed specificationfor a configuration

    Contains APIsfor UI, event handling, datastorage, networks, timers,

    Minimum requirements for devices (screen

    size, input possibilities, ...) For mobile phones:Mobile Information

    Device Profile (MIDP)

  • 8/7/2019 Java ME

    11/27

    Profiles

  • 8/7/2019 Java ME

    12/27

    Sample Architecture of a Phone

  • 8/7/2019 Java ME

    13/27

    Java ME Examples

    Motorola/MOTORAZR V3

    CLDC 1.0

    MIDP 2.0 Nokia N70

    CLDC 1.1

    MIDP 2.0

    SonyEricssonP990i CLDC 1.1

    MIDP 2.0

    CDC 1.0

    Personal Profile

  • 8/7/2019 Java ME

    14/27

    Java ME Examples

    Nokia N86 8MP

    CLDC 1.1

    MIDP 2.1

    MSA (Subset)

    Amazon Kindle 2

    CDC

  • 8/7/2019 Java ME

    15/27

    MIDlet MIDP does not support the running of

    applications that use a static main method as

    their entry point, nor calling the System.exit

    method in order to terminate.

    Instead, we use a MIDlet, which is a MID

    Profile application.

  • 8/7/2019 Java ME

    16/27

    MIDlet Every application must extend

    javax.microedition.midlet.MIDletclass to

    allow the application management software

    to:

    control the MIDlet

    be able to retrieve properties from theapplication descriptor

    notify and request state changes

  • 8/7/2019 Java ME

    17/27

    MIDlet The extending class is the main class of the

    application.

    The MIDlet class defines abstract methods

    that the main class implements (for

    example: startApp(), destroyApp(),

    notifyDestroyed()).

  • 8/7/2019 Java ME

    18/27

    MIDlet Suite One or more MIDlets are packaged together

    into aMIDlet suite, composed of:

    JAR (Java archive) file

    JAD (Java Application Descriptor) file

    All the user-defined classes and resources

    required by the suite's MIDlets must be inthe JAR file.

  • 8/7/2019 Java ME

    19/27

    Creating a MIDlet import javax.microedition.midlet.*;

    import javax.microedition.lcdui.*;

    public class HelloMidlet extends MIDlet {private Display display;TextBox box = null;public HelloMidlet() {}public void startApp() {

    display = Display.getDisplay(this);box = new TextBox("Simple Example", "Hello World", 20, 0);display.setCurrent(box);

    }

    public void pauseApp() {}public void destroyApp(boolean unconditional) {}

    }

  • 8/7/2019 Java ME

    20/27

    Event Handling

  • 8/7/2019 Java ME

    21/27

    Listener Implement the Listener-Interface to get

    informed:

    CommandListener: commandAction()Notificationwhen e.g. a menu item has been selected

    ItemCommandListener: commandAction()Used for

    events for individual items

    ItemStateListener: itemStateChanged()When an UIelement has been changed

  • 8/7/2019 Java ME

    22/27

    Command-Types

  • 8/7/2019 Java ME

    23/27

    Command-Exit Class HelloWorldMIDlet:

    implements CommandListener

    Define new command (member variable):

    private Command cmdExit;

    Create it in the constructor:

    cmdExit= new Command(Exit, Command.EXIT, 1);frmMain.addCommand(cmdExit);

    frmMain.setCommandListener(this);

  • 8/7/2019 Java ME

    24/27

    Command Handling Method defined in the base class CommandListener:

    public void commandAction(Commandc,

    Displayable d){

    if (c == cmdExit)

    {destroyApp(true);

    notifyDestroyed();

    }

    }

  • 8/7/2019 Java ME

    25/27

  • 8/7/2019 Java ME

    26/27

    Discussion

  • 8/7/2019 Java ME

    27/27