Mobile application development J2ME U N I T I I



Similar documents
MIDlet development with J2ME and MIDP

Mobile Application Development

Java Platform, Micro Edition (Java ME) Mokoena F.R. The 7046 Team

Tutorial: Development of Interactive Applications for Mobile Devices

Introduction to Mobile Phone. Programming in Java Me

Mobile Software Application Development. Tutorial. Caesar Ogole. April 2006

Development of Java ME

::. Contenuti della lezione *+ ') $ &,!!!$!-,.../- ' % + &

J2ME: Step by step. Presented by developerworks, your source for great tutorials ibm.com/developerworks

WHAT ARE PACKAGES? A package is a collection of related classes. This is similar to the notion that a class is a collection of related methods.

DESIGNING SHIFT CALENDAR FOR MOBILE PHONE

Nokia 9210i/9290 Communicators and PersonalJava TM Application Development

Installing Java. Table of contents

How to use the Eclipse IDE for Java Application Development

Java Language Tools COPYRIGHTED MATERIAL. Part 1. In this part...

The Software Engineering of Mobile Application Development

Practice Fusion API Client Installation Guide for Windows

5. More on app development

1 Mobile and Ubiquitous User Interfaces

Introduction to Android Programming (CS5248 Fall 2015)

Java Software Development Kit (JDK 5.0 Update 14) Installation Step by Step Instructions

Developing Wireless Applications using Java Technology. Computing Is Ubiquitous

Creating a Java application using Perfect Developer and the Java Develo...

Opening a Command Shell

Appendix A Using the Java Compiler

Android Basics. Xin Yang

The Java Virtual Machine and Mobile Devices. John Buford, Ph.D. Oct 2003 Presented to Gordon College CS 311

Mobile Application Development. MIDP & GUI Programmierung

Supplement I.C. Creating, Compiling and Running Java Programs from the Command Window

2 Introduction to Java. Introduction to Programming 1 1

LAB 1. Familiarization of Rational Rose Environment And UML for small Java Application Development

Mobile Application Development Android

An Overview of Java. overview-1

Technical Note. Micron Flash Data Integrator (FDI) Support for Java Applications. Introduction. Definition

A Short Introduction to Writing Java Code. Zoltán Majó

Getting Started with Android Development

Developing In Eclipse, with ADT

Java with Eclipse: Setup & Getting Started

Installing (1.8.7) 9/2/ Installing jgrasp

Android Development Setup [Revision Date: 02/16/11]

Mobile Operating Systems. Week I

Android Setup Phase 2

APPLICATION PROGRAMMING - MOBILE COMPUTING Mobile Computing

Crash Course in Java

Location-Based Information Systems

Java ME & NetBeans Mobility. Petr Suchomel Architect, NetBeans Mobility Sun Microsystems

Android Environment SDK

Application Servers - BEA WebLogic. Installing the Application Server

How to Create an Android Application using Eclipse on Windows 7

Android Programming. Høgskolen i Telemark Telemark University College. Cuong Nguyen,

Click Start > Control Panel > System icon to open System Properties dialog box. Click Advanced > Environment Variables.

The "Eclipse Classic" version is recommended. Otherwise, a Java or RCP version of Eclipse is recommended.

Right now, the latest and greatest version of Java available for download is Start with this link to find out more about it

CSA Software Listing Table of Contents. Both Windows and Mac platforms are supported.

Project: E290 - MOBILE COMMERCE APPLICATION DEVELOPMENT

Java Programming Unit 1. Your first Java Program Eclipse IDE

IOIO for Android Beginners Guide Introduction

Android Mobile App Building Tutorial

EMC Documentum Composer

Java Bluetooth stack Acceptance Test Plan Version 1.0

Gentran Integration Suite. Archiving and Purging. Version 4.2

Eclipse installation, configuration and operation

JavaOne Hands-On Lab LAB-6400 Create Your Own Mobile Game

Glassfish, JAVA EE, Servlets, JSP, EJB

Mobile Application Languages XML, Java, J2ME and JavaCard Lesson 04 Java

Matisse Installation Guide for MS Windows. 10th Edition

Android Development Exercises Version Hands On Exercises for. Android Development. v

Oracle Java Micro Edition Software Development Kit

A Sample OFBiz application implementing remote access via RMI and SOAP Table of contents

How To Run A Hello World On Android (Jdk) On A Microsoft Ds.Io (Windows) Or Android Or Android On A Pc Or Android 4 (

Intel Integrated Native Developer Experience (INDE): IDE Integration for Android*

Matisse Installation Guide for MS Windows

Packaging and Deploying Java Projects in Forte

Installing the Android SDK

Supplement I.B: Installing and Configuring JDK 1.6

Java ME Clients for XML Web Services

SETTING UP YOUR JAVA DEVELOPER ENVIRONMENT

An Overview of Oracle Forms Server Architecture. An Oracle Technical White Paper April 2000

Tutorial on Basic Android Setup

Android Environment SDK

Supplement I.B: Installing and Configuring JDK 1.6

Chapter 1 Java Program Design and Development

Installing Java (Windows) and Writing your First Program

Server Setup and Configuration

How To Develop An Android App On An Android Device

User s Guide. Sun Java TM Wireless Toolkit for CLDC Version Sun Microsystems, Inc.

Basic Android Setup Windows Version

JBoss SOAP Web Services User Guide. Version: M5

Security Evaluation of J2ME CLDC Embedded Java Platform

Understanding Java Virtual Machine Selection in InstallAnywhere

Python for Series 60 Platform

Fahim Uddin 1. Java SDK

Intel System Event Log (SEL) Viewer Utility. User Guide SELViewer Version 10.0 /11.0 December 2012 Document number: G

New Technology Introduction: Android Studio with PushBot

Canto Integration Platform (CIP)

Transcription:

Mobile application development J2ME U N I T I I

Overview J2Me Layered Architecture Small Computing Device requirements Run Time Environment Java Application Descriptor File Java Archive File MIDlet Programming Life cycle methods Event Handling User Interfaces & Device Data Java Language for J2ME J2Me software development Kits Hello World J2ME Style J2ME Wireless Tool kit

J2ME Architecture MIDP Applications OEM-Specific Applications Native Applications MIDP OEM-Specific Classes CLDC Native System Software/Host Operating System Mobile Information Device (MID)

J2ME Architecture J2ME architecture enables an application to be scaled on constraints of small computing device J2ME architecture consists of layers located above the native operating system collectively referred to as the connected Limited Device Configuration(CLDC) and forms the runtime environment. It consists of three software layers JVM Directly interacts with native operating system Profile consists of minimum set of APIs MIDP contains java API s for user network connections, persistent storage and the user interface. OEM Original Equipment Manufacturer has two components OEM classes used by MIDP to access device specific features such as SMS etc OEM applications programs provided by OEM such as address book

J2ME Architecture CLDC java.lang java.io java.util javax.microedition.io MIDP javax.microedition.lcdui javax.microedition.midlet javax.microedition.rms

Small Computing Device Requirements Hardware Display Memory Input Device Connectivity Minimum Requirement 96 X 54 Pixels 65,536 colors 32 KB workspace 128KB MIDP Implementation 8KB for MIDlets run The device has the equivalent of a keypad that allows the user to type the numbers 0 through 9,together with the equivalent of arrow keys and a select button HTTP 1.1; TCP/IP

Run Time Environment 7 One or more MIDlets are packaged together into a MIDlet 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 in the JAR file. J2ME

JAR & JAD The JAR file must also include a manifest that describe the MIDlets in the suite. 8 The application descriptor (JAD) contains similar information, and is used by devices to obtain information about a MIDlet suite without having to download and install the MIDlet suite first. J2ME

JAD.. Used by AMS to manage MIDlets Has to be supplied to run a CLDC-compliant app File extension is. jad Some attributes of the manifest file are duplicated in the JAD MUST match information in the JAR Manifest otherwise MIDlet won t load The attributes are Name/Value pair, separated by a colon and optional whitespace

Sample JAD MIDlet-1: MyMIDlet, MyMIDlet.png, MyMIDlet MIDlet-2: FirstConnection,, FirstConnection MIDlet-Jar-Size: 100 MIDlet-Jar-URL: MyMIDlet.jar MIDlet-Name: MyMIDlet MIDlet-Vendor: Switchback Software MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.1 MicroEdition-Profile: MIDP-2.0

MIDlet Programming MIDP applications are known as MIDlets MIDlet is the basic application Similar to the J2SE applet GUI based MIDlet Suite Grouping of related MIDlets as a single unit All the MIDlets of a MIDlet are executed as a single instance security for applications that share resources or data

MIDP Application Lifecycle MIDlets move from state to state in the lifecycle, as indicated. Pause Start acquire resources and start executing Pause release resources and become quiescent (wait) Destroy release all resources, destroy threads, and end all activity pauseapp startapp Active destroyapp destroyapp Destroyed

Lifecycle Methods startapp() Can be called multiple times, need to prevent subsequent calls to startapp() from starting the UI at the beginning a wizard pauseapp() usually used to release any resources that we re holding on too. destroyapp() any cleanup, prevents the user from exiting the app if a submission of data is in progress. Screen interactions are handled by the commandaction() which we ll talk about shortly...

startapp() Starts the applications, called from the AMS Maybe called multiple times, so needs to account for both initial and normal running semantics Should try and return quickly because the applications Displayable is not shown until after this method exits. Throws MIDletStateChangeException if app can t start now, but might be able to start at a later time. Prevents subsequent calls to startapp() from starting the UI at the beginning of the wizard

startapp() protected void startapp() throws javax.microedition.midlet. } MIDletStateChangeException { if (false == this.m_binitialized) { } m_binitialized = true; startui();

MIDP Mobile Information Device Profile Targeted at medium- to low-end cell phones and two-way pagers Spec addresses issues such as Application life cycle User interface Persistence storage Networking

MIDlets MIDP application on a device that is managed by the AMS MIDlet suite is a JAR file that contains 1 or more MIDlets MIDlet-<n> contains info about that MIDlet MIDlet-1: MyMIDlet, MyMIDlet.png, MyMIDlet MIDlet-2: FirstConnection,, FirstConnection <n> MIDlets get packaged in the same JAR file AMS gives choice for loading each MIDlet

Sample Code import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class HiMIDlet extends MIDlet { private TextBox textbox; public HiMIDlet() { textbox = new TextBox ("", "Hello World!", 20, 0); } public void startapp() { Display.getDisplay(this).setCurrent(textbox); } public void pauseapp() { } public void destroyapp(boolean unconditional) {} }

Event Handling of J2ME A MIDlet is a event based application When a user interacts with a MIDlet, events are generated and the application is modified to handle and respond to these events. The application is notified of such events through callbacks. All routines executed in the MIDlet are invoked in response to an event reported to the MIDlet by the application manager The initial event that occurs is when the MIDlet is started and the application manager invokes the startapp() method Each screen is associated with CommandListener interface A CommandListener monitors user events with screen and causes the appropriate code to be executed based on the current event.. Screen events comes under High level events Low-level events represent single key presses and releases

J2ME User Interfaces The Design of user interface for a MIDlet depends on the restrictions of small computing device There are two types of user interfaces supported by J2ME High Level UI (Screen ) Low Level UI (Canvas ) A Form is the most commonly invoked user interface A user enters information into for by using Choice element, TextBox, TextField, DateField elements. Other user interface elements are StringItem contains text List = contains List of Items Alert to alert the user Ticker- scrollable text etc..

J2ME Device Data Small computing devices don t have the resources necessary to run an onboard database management system (DBMS) A MIDlet uses RecordStore MIDP class and two MIDP interfaces called RecordComparator and RecordFilter to write and read persistent data. RecordStore class contains methods used to write and read persistent data.

Java Language for J2ME CDC implements the full J2SE available but CLDC implements stripped down J2SE due to resource constraints 1. Floating point math is most notable feature of J2ME which requires extra hardware 2. J2ME does not support finalize() method 3. Reduced number of error handling exceptions are supported in J2ME.because exception handling drains system resources 4. JVM for small computing devices requires a custom class loader supplied by the device manufacturer 5. J2ME does not support ThreadGroup class 6. References and Reflection classes are not supported by J2ME 7. J2ME does not support Security Manager instead it uses class file verification to protect applications with a two step process 1. Pre verification -- outside the device and 2. verification --after loading the MIDlet into the device

J2ME Software Development Kits A MIDlet is built using free software packages that are downloadable form java.sun.com Three Packages are needed 1. Java Development Kit (1.3 or greater ) java.sun.com/j2se/downloads.html - It contains java compiler and jar.exe file which is used to crate Java achieve file (JAR ) 2. Connected Limited Device Configuration(CLDC) java.sun.com/products/cldc/ -unzip CLDC on to d:\j2me directory - CLDC package creates j2me_cldc sub directory under j2me - j2me_cldc has bin subdirectory that contains KVM and preverifier executable files - add j2me\j2me_cldc\bin\win32 subdirectory to PATH environment variable 3. Mobile Information Device Profile (MIDP) java.sun.com/products/midp/ - unzip MIDP file creates a midp directory1.0.3fcs directory which also contains bin sub directory - add j2me\midp1.0.3fcs\bin subdirectory to PATH environment variable

J2ME Software Development Kits Set the CLASSPATH to d:\j2me\mipdp1.0.3fcs\classes Set the MIDP_HOME environment variable to d:\j2me\midp1.0.3fcs.

Hello World J2ME Style The directories used to develop HelloWorld MIDlet J2me J2me\src J2me\src\greeting\j2me\tmp_classes (greetings is the user defined directory) J2me\midlets Steps to Run HelloWorld MIDlet 1. Develop the source code HelloWorld.java 2. Compile HelloWorld.java 3. Pre verify the HelloWorld Class file 4. Running HelloWorld

HelloWorld MIDlet 1. HelloWorld MIDlet is created by defining HelloWorld class import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class HelloWorld extends MIDlet { private TextBox textbox; public HiMIDlet() { textbox = new TextBox ("", "Hello World!", 20, 0); } public void startapp() { Display.getDisplay(this).setCurrent(textbox); } public void pauseapp() { } public void destroyapp(boolean unconditional) {} }

HelloWorld MIDlet 2 Compilling Hello WorldelloWorld -- j2me\src\greeting is the current directory Enter the following commamnd at the command line javac d d:\j2me\tmp_classes target 1.1 bootclasspath d:\j2me\midp10.3fcs\clases HelloWorld.java The bootclasspath option must be used when compiling a MIDlet which points to the startup files( java bootstrap files ) The compiler produces HelloWorld.class in the j2me\temp_classes\greetings directory 3. Prevrify HelloWorld.class by executing the following command Preverify d d:\j2me\classes classpath d:\j2me\midp1.0.3fcs\classes d:\j2me\tmp_classes -d option places the class file within the tmp_classes directory -classpath option points to the location of the library classes that come with the MIDP

HelloWorld MIDlet 4. Running HelloWorld A MIDlet should be tested in an emulator before being downloaded to a small computing device. An emulator is software that simmulates how a MIDlet will run in a small computing device There are Two ways to run a MIDlet 1. Invoking the MIDletclass or 2. Running the MIDlet from JAR file Enter the following command for running MIDlet class without JAR file midp classpath d:\j2me\classes greeting.helloworld

Installation of Java Wireless Toolkit (J2ME) 1) If the Java Development Kit (JDK) is not there or only having the Java Runtime Environment (JRE) installed, install the latest JDK from http://java.sun.com/javase/downloads/index.jsp. Current stable release of Java is JDK 6 Update 7 2) Next, download the Java Wireless Toolkit (formerly called J2ME Wireless Toolkit) from: http://java.sun.com/products/sjwtoolkit/download.html. 3) Run the installer (for example, for Windows it is: sun_java_wireless_toolkit- 2_5_2-windows.exe). The installer checks whether a compatible Java environment has been preinstalled. If not, it is necessary to uninstall old versions of Java and perform Step 1 again.

Steps to run MIDlet in toolkit: 1. Start -> All Programs -> Sun Java Tool Kit -> Wireless Tool Kit 2. Click New Project Enter Project Name -> Enter Class Name -> Click on Create Project. The toolkit will create a project directory for you using the project name you provide. 3. Choose appropriate API Selection and Configurations. 4. Place Java Source file in WTK2.1 / WTK2.2\apps\projectname\src 5. Build the Project. 6. Run the Project.

HelloWorld Using J2ME Wireless Tool Kit import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class HelloWorld extends MIDlet { private Form form; private Display display; public HelloWorld() { super(); } public void startapp() { form = new Form("Hello World"); String msg = "Hello World!!!!!!!"; form.append(msg); display = Display.getDisplay(this); display.setcurrent(form); } public void pauseapp(){} public void destroyapp(boolean unconditional) { notifydestroyed(); } }

Sun s J2ME Wireless Toolkit To run the toolkit itself, select the KToolbar shortcut. You should see the following screen.

Sun s J2ME Wireless Toolkit The J2ME Wireless Toolkit works with projects, where the end result of each project is one MIDlet suite. The toolkit works with one project at a time. You can change properties of the current project, build the project, and run the project in a device emulator. Several example projects come installed with the toolkit; we'll look at these later. Click on New Project in the button bar. The toolkit prompts you for a project name and the name of a MIDlet class in the project. Fill in HelloSuite and HelloMIDlet as shown below.

Nokia J2ME SDK

Important Questions 1. Explain J2ME architecture with a neat diagram. 2. Develop a hello world program using J2ME style. 3. Explain Event processing and Data Management in J2ME 4. Explain how multiple MIDlets are distributed in a single MIDlet suite 5. Explain the java language features of J2ME 6. Explain the features of J2ME wireless toolkit