Java me clients
Download
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 l.jpg

Java ME Clients

Mobile Computing

Bruce Scharlau, University of Aberdeen, 2010

Some materials from MobEdu.net


Constantly changing market means focus on learning basics l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
    ‘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 l.jpg
    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 l.jpg
    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 l.jpg
    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 l.jpg
    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 l.jpg
    Midlets are packaged in jars with required resources implementing three methods

    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 l.jpg
    Jad and Manifest are similar required files for Java ME apps implementing three methods

    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 l.jpg
    Manifest goes in the jar file implementing three methods

    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 l.jpg
    The JAD references the JAR implementing three methods

    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 l.jpg
    The JAD is validated by the AMS implementing three methods(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 l.jpg
    JAD used for over the air (OTA) installation implementing three methods

    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 l.jpg
    MIDlet Development implementing three methods

    • 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 l.jpg
    Preverify to check that classes are correct implementing three methods

    • 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 l.jpg
    Obfuscate to shrink the application implementing three methods

    Renames methods and variables with shorter names

    Optional and recommended

    Bruce Scharlau, University of Aberdeen, 2010


    Jar and run in emulator l.jpg
    Jar and run in emulator implementing three methods

    Create bundle with resources for deployment

    Use basic or complex emulator

    Bruce Scharlau, University of Aberdeen, 2010


    Run on device for final check l.jpg
    Run on device for final check implementing three methods

    Running on real devices is the final check

    Start with low end device

    Bruce Scharlau, University of Aberdeen, 2010


    Midlet must implement three methods l.jpg
    MIDlet must implement three methods: implementing 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 l.jpg
    MIDlet needs other key parts implementing three methods

    • 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 l.jpg
    MIDlet needs to initialise and create variables implementing three methods

    // 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 l.jpg
    MIDlet use startApp() to move to active state implementing three methods

    • 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 l.jpg
    The commandAction() method handles the incoming commands implementing three methods

    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 l.jpg
    If it’s not used leave it empty implementing three methods

    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 l.jpg
    Before and after start implementing three methods

    Bruce Scharlau, University of Aberdeen, 2010


    Three levels of software for mobiles l.jpg
    Three levels of software for mobiles implementing three methods

    • 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 l.jpg

    Class implementing three methods

    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 l.jpg
    Allow garbage collection to do its job implementing three methods

    • 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 l.jpg
    Pay attention to your memory usage to improve performance implementing three methods

    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 l.jpg
    Use linear data structures to conserve memory implementing three methods

    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 l.jpg
    Avoid small classes in favour of larger ones implementing three methods

    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 l.jpg
    Avoid dependencies where possible implementing three methods

    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 l.jpg
    Use Arrays instead of Vectors where possible implementing three methods

    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 l.jpg
    Use StringBuffer instead of String implementing three methods

    Method Allocated bytes Allocated objects

    useString 39,000 450

    useStringBuffer 304 5

    Bruce Scharlau, University of Aberdeen, 2010


    Summary l.jpg
    Summary implementing three methods

    Use memory responsibly for best performance

    Create clients using appropriate CLDC and MIDP libraries

    Bruce Scharlau, University of Aberdeen, 2010


    ad