Java for Mobile Devices

Slides:



Advertisements
Similar presentations
MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
Advertisements

Java 2D Training. Basic Tools Java SDK 1.4x Wireless Toolkit 2.x NetBeans IDE + mobility pack Global Code editor Text Comparer Tools Graphics Editor Sprite.
1 Mobile Software Development Framework: TinyOS, J2ME 10/2/2012 Y. Richard Yang.
Pengantar Teknologi Mobile 12
Introduction of J2ME Mobile solutions. Overview What is J2ME. How does J2ME work? Java J2ME Carriers and Products. The Two Configuration of J2ME. Profiles.
J2ME 25 July Overview  What is J2ME?  The CLDC and CDC configurations  MIDP and MIDlets  Development Tools  Demonstrations.
Writing Your First MIDlet Running JAVA on a Cell Phone Jon A. Batcheller January 27, 2004.
UNDERSTANDING JAVA APIS FOR MOBILE DEVICES v0.01.
Introduction to Java 2 Micro Edition Mark Balbes, Ph.D. Senior Software Engineer Jeff Brown Senior Software Engineer.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 10 Java for MIDs Rob Pooley
Quality Assurance and Testing of J2ME Programs for Mobiles Phones.
Developing an Application with J2ME Technology Scott Palmer, Nat Panchee, Judy Sullivan, Karen Thabet, Sten Westgard.
J2ME RMI 1 Java 2 Platform, Micro Edition Implementation of J2ME RMI Application Farooq Sheikh.
J2ME for Palm Speaker: Chen-Nien Tsai Adviser: Kai-Wei Ke.
Introduction to Mobility Java Technology Mobile and Wireless Networks.
Developing Software for Wireless Devices
J2ME Prepared by: - Gaery- Ronny - Alan- Andy. Why Technology for Mobile Devices? The nature of wireless devices is changing Old devices: All the software.
PDA Programming Using J2ME Presenter :涂俊凱 Date : 2003/4/8.
Making Cell Phone Games An Overview Ray Ratelis Guild Software, Inc.
Developing J2ME Applications Mobile and Wireless Networks.
The 21th century Repairman Agenda Introduction J2EE J2ME Demonstration.
Cosc 4730 Phone Programming in Java An Introduction.
Java Platform, Micro Edition (J2ME)
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
J2ME and WAP Technologies CSCI – Independent Study Fall 2002 Presented by: Kashif Syed.
J2ME -Kushal Modi(09BIT056).
J2ME Java for Mobile Environments Based on J2ME In A Nutshell, by Kim Topley, O’Reilly & Associates Inc., 2002, and Tetris by Alexei Patinov.
An Introduction to the Java ME Project Jens A Andersson.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 Using the KToolbar Rob Pooley
Platforms and tools for Web Services and Mobile Applications J2ME based Applications Bent Thomsen Aalborg University 3rd and 4th of June 2004.
1 Mobile Software Development Framework 4/14/2009 Richard Yang.
Getting Started with JXTA for J2ME Advisor : Dr. Ching-Long Yeh Report : DI.2, 洪泰昌 ( ) Course: XML 文件管理.
Michael Brockway Advanced Applications Development in Java J2ME -- Introduction l Introduction / Overview l Java 2 Micro Edition n CLDC n MIDP l Examples.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 11 J2ME and MIDlets Rob Pooley
Mobile Applications and Java ME
Framework and application bytecode size CLDC MIDP kXML parser Utility classes Graphics Logic (MIDlet) Application Data (XML file)
Computer Science Wi-Fi App using J2ME and MVC Architecture Advisor : Dr. Chung-E Wang Department of Computer Science Sacramento State University Date:
J2ME Presented by May Sayed & Menna Hawash. Outline Introduction “Java Technology” Introduction “What is J2ME?” J2ME Architecture J2ME Core Concepts 
Java 2 Micro Edition (J2ME) and the world of java
PROG Mobile Java Application Development PROG Mobile Java Application Development BlackBerry App Lifecycle Java ME API.
1Basics of J2ME. 2 Objectives –Understand the different java API’s and how the mobile edition API’s fit in –Understand what a mobile configuration and.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 lcdui Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 13 lcdui and OXO Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 14 Various MIDlet examples Rob Pooley
8-January-2003cse ProjectOverview © 2003 University of Washington1 Project Overview CSE 403, Winter 2003 Software Engineering
Other Popular Java Technologies Internationalization in Java Graphics Programming in Java Security Programming in Java Collections and Data Structures.
Java 2 Micro Edition The Connected, Limited Device Configuration.
Java 2 Platform, Micro Edition (J2ME)
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
Mobile Programming Mobile Programming - Ordibehesht Ordibehesht 1390.
Enhanced mobile services in Java enabled phones Björn Hjelt Sonera zed ltd Supervisor: Professor Jorma Jormakka.
J2ME Programming. Java2 Micro edition Introduction 년 5 월 26 일 CLDC, MIDP 라이브러리 Reference :
CSE403: MIDlets and Ant1 MIDlets and Ant April 3, 2003 Shane Cantrell Zach Crisman.
Advance Computer Programming Market for Java ME The Java ME Platform – Java 2 Micro Edition (J2ME) combines a resource- constrained JVM and a set of Java.
Visual Mobile Applications with Netbeans 6.0 Your Name Sun Campus Ambassador Your Address.
The Java Platform Micro Edition Java ME
CS434/534: Topics in Networked (Networking) Systems WSN/Mobile Systems Yang (Richard) Yang Computer Science Department Yale University 208A Watson
Java N Amanquah.
Part II Software When developing software there are several particularities to be aware of: Java is widespread used because of the platform independence.
Programming of Handheld and Mobile Devices
MOBILE DEVICE OPERATING SYSTEM
Wireless Instant Messaging Using J2ME
Mobile Software Development Framework: TinyOS, J2ME
Mobile Software Development Framework
By Jeff Heaton An Overview of J2ME By Jeff Heaton
J2ME Command Class.
Session 10 J2ME Prof. Sridhar Iyer IIT Bombay
Introduction of J2ME Mobile solutions.
Shane Cantrell Zach Crisman
Presentation transcript:

Java for Mobile Devices Objectives To present some elements on J2ME. To give the basic steps on how to work with J2ME. To develop some examples. 2/17/2019 Mobile Applications - Lecture 1

What is J2ME (JAVA MICRO EDITION) J2ME = Java solution for small electronic commodities. - mobile phones, pagers, PDA, set-top boxes, etc J2ME architecture Small Java virtual machines: KVM and CVM Configurations and Profiles – Java Libraries and APIs Various tools for deployment and device configuration Why J2ME? It is device independent. It reuses some of the Java classes. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Some Terminology J2ME = Java Micro Edition CLDC = Connected Limited Device Configuration CDC = Connected Device Configuration KVM = Kilobyte virtual machine. CVM = Consumer and embedded virtual machine. MIDP = Mobile information device profile. PDAP = Personal digital assistant device. MIDlet = Java program for mobile devices. 2/17/2019 Mobile Applications - Lecture 1

J2ME General Architecture Of Interest of us 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 CLDC CLDC defines some common features / Java classes for small devices. CLDC considers: - Limited memory: 160 KB to 512 KB of total memory - Limited computation: 16-bit or 32-bit processor with at least 25 Mhz speed - Connectivity to some kind of networking Low power consumption CLDC is a collection of Java packages for A subset of Java language and virtual machine features A subset of core Java libraries (java.lang and java.util) Basic input/output (java.io) Basic networking support (javax.microedition.io) Some of those might not be scaled down (see the documentation for changes) 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 MIDProfile The MIDP standard defines a MID as a device with the following minimum characteristics: Small Display: A screen size of at least 96 x 54 pixels with at least a 1-bit display depth. Input: A one-handed keyboard, two-handed keyboard, or touch screen. Memory: 32 KB of volatile memory for the Java runtime (heap); 128 KB of non-volatile memory for the MIDP components; 8 KB of non-volatile memory for persistent data . Networking: Two-way intermittent connection, usually wireless, with limited bandwidth 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 MIDProfile (1) The main functions of MIDProfile are: Application Life Cycle Management The MIDP includes the javax.microedition.midlet package, which contains classes and methods for starting, pausing, and destroying applications in the host environment. User Interface and Events The MIDP also provides the javax.microedition.lcdui packages, which include classes and interfaces for creating GUI components for applications. Network Connectivity The MIDP extends the ContentConnection interface of the Generic Connection Framework by providing the HttpConnection interface, as well as a subset implementation of the HTTP protocol. Storing Data on Device The MIDP also provides the javax.microedition.rms package, which implements a record-based database management system. This provides applications with the capability to store data on the device. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 MIDlet Life Cycle javax.microedition.midlet.MIDlet is an abstract class defines three life cycle methods: pauseApp(), startApp(), and destroyApp(). MIDlet cycles: Paused, Active, Destroyed. public void startApp( ) This method indicates that the MIDlet is moving from a paused state to an active state. Here, the MIDlet will typically initialize any objects that are required while the MIDlet is active, and set the current display. public void pauseApp( ) This method is called when the MIDlet is moving from an active state to a paused state. This means that it will pause any threads that are currently active, as well as optionally setting the next display to be shown when the MIDlet is re-activated. Data can be persisted, if necessary, and retrieved later when the MIDlet is activated again. public void destroyApp(boolean unconditional) This method indicates that the MIDlet is moving to the destroyed state. It should free or close all resources that have been acquired during the life of the MIDlet. In addition, the method should persist any data that it wishes to save for future use. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 MIDlet Skeleton import javax.microedition.midlet.*; public class MyMIDlet extends MIDlet { public MyMIDlet( ) { // constructor } public void startApp( ) { // entering active state } public void pauseApp( ) { // entering paused state } public void destroyApp( boolean unconditional) { // entering destroyed state } } 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Example import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class HelloWorld extends MIDlet{ private Display display; TextBox textbox; public HelloWorld(){ display = Display.getDisplay(this); textbox = new TextBox("HelloWorld","HelloWorld.",500,0); } public void startApp(){ display.setCurrent(textbox);} public void pauseApp(){} public void destroyApp(boolean unconditional){} 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Run a MIDlet Hard but Safer Way: Write the MIDlet (Java program) Compile the MIDlet's source code (javac) javac –bootclasspath c:\j2me\midp2.0fcs\classes HelloWorld.java Preverify the MIDlet's class file () preverify –classpath c:\j2me\midp2.0fcs\classes –d HelloWorld Package the application in a JAR file  It is optional jar cvf payment.jar PaymentMidlet.class Run the MIDlet midp HelloWorld 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Run a MIDlet (1) Simple Way by Using a J2ME Toolkit (several emulators). Write the MIDlet (Java program). Create a new J2ME project. Add the java file in the src folder of the project. Build the project. Run the project using the emulator you want. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Run a MIDlet (2) 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class Welcome extends MIDlet implements CommandListener {private Display display; // Reference to Display object for this MIDlet private TextBox tbMain; // A Textbox to display a message private Command cmExit; // A Command to exit the MIDlet public Welcome() { display = Display.getDisplay(this); cmExit = new Command("Exit", Command.SCREEN, 1); tbMain = new TextBox ("Welcome", "Hello to J2ME", 50, 0); tbMain.addCommand(cmExit); tbMain.setCommandListener(this); } public void startApp() { display.setCurrent(tbMain);} // Called by application manager to start the MIDlet. public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c, Displayable s) if (c == cmExit) { destroyApp(false); notifyDestroyed(); } 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Deploy a MIDlet Deploy = Transfer the jar + jad files to your mobile. jar – archive of the MIDlet. jad – (java application description) MIDlet-1: Hello,,HelloMidlet MIDlet-Name: HelloMidlet MIDlet-Version: 1.0 MIDlet-Vendor: ORA MIDlet-Jar-URL: HelloMidlet.jar MIDlet-Jar-Size: 863 The jad file can also provide other elements e.g. parameters. Several ways to deploy depending on network, phone etc. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Almost the Same Java CLDC – contains some classes from java.lang.*: Boolean, Byte, Character, Class, Integer, Long, Math, Object, Runnable, Runtime, Short, String, StringBuffer, System, Thread, Throwable java.io.*: ByteArrayInputStream, ByteArrayOutputStream, DataInput, DataOutput, DataInputStream, DataOutputStream, InputStream, OutputStream, InputStreamReader, OutputStreamWriter, PrintStream, Reader, Writer java.util.*: Calendar, Date, Enumeration, Hashtable, Random, Stack, TimeZone, Vector Plus 20+ classes to work with Exceptions Some of the classes are scaled down quite a lot. 2/17/2019 Mobile Applications - Lecture 1

Certainly the Same New Java MIDP – contains the following new packages: javax.microedition.midlet.*; MIDlet and MIDletStateChangeException; javax.microedition.lcdui.*; several classes for UI – Command, Display, TextBox, TextField, Graphics, Canvas, etc. javax.microedition.rms.*; RecordStore + etc. Old Packages java.util.*: Timer and TimerTask. 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 MIDlet-Name: Show Properties MIDlet MIDlet-Version: 1.0.1 MIDlet-Vendor: Core J2ME MIDlet-1: ShowProps, , ShowProperties MicroEdition-Profile: MIDP-1.0 MicroEdition-Configuration: CLDC-1.0 MIDlet-Data-Size: 1500 getAppProperty() import javax.microedition.midlet.*; public class ShowProperties extends MIDlet { public void startApp() { System.out.println("Vendor: " + getAppProperty("MIDlet-Vendor")); System.out.println("Description: " + getAppProperty("MIDlet-Description")); System.out.println("JadFile Version: " + getAppProperty("JadFile-Version")); System.out.println("MIDlet-Data-Size: " + getAppProperty("MIDlet-Data-Size")); Runtime rtime = Runtime.getRuntime(); System.out.println("Total memory: " + rtime.totalMemory()); System.out.println("Free memory: " + rtime.freeMemory()); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } 2/17/2019 Mobile Applications - Lecture 1

Mobile Applications - Lecture 1 Problems to Solve: Read about the CLDC and MIDP References: 1.Jonathan Knudsen, Wireless Java, APress, 2003 2. Quasay Madmud, Learning Wireless Java, eBook from http://proquest.safaribooksonline.com/?x=1&mode=toc&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-243-2&g=&catid=&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1&n=1&d=1&p=1&a=0 2/17/2019 Mobile Applications - Lecture 1