Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 8 CDC andJ2ME Rob Pooley

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 10 API Review; Where Next.
Advertisements

MIDP Mobile Information Device Profile Johnny Yau CIS 642 Prof. Insup Lee.
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.
Android architecture overview
Introduction to Android Mohammad A. Gowayyed CS334-Spring 2014.
Multimedia Network Communications Subject:T0934 / Multimedia Programming Foundation Session:13 Tahun:2009 Versi:1/0.
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.
Bluetooth and java – a perfect match? Sean O Sullivan ceo Nordic Bluetooth, October 5th, 2001.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 10 Java for MIDs Rob Pooley
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Cosc 4730 Blackberry: Record Store & SQLite. Introduction RecordStore – Comes from JavaME, MIDP 1.0 On some phone who where you may not have a filesystem.
Developing an Application with J2ME Technology Scott Palmer, Nat Panchee, Judy Sullivan, Karen Thabet, Sten Westgard.
JAVA Technology. Java Technology Java technology is a portfolio of products that are based on the power of networks and the idea that the same software.
J2ME RMI 1 Java 2 Platform, Micro Edition Implementation of J2ME RMI Application Farooq Sheikh.
JAVA ME PARALLELISM AND IMPLEMENTATIONS FOR EMBEDDED DEVICES Adam Stirtan.
JETT 2003 Java.compareTo(C++). JAVA Java Platform consists of 4 parts: –Java Language –Java API –Java class format –Java Virtual Machine.
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.
V0.01 © 2009 Research In Motion Limited Understanding Java APIs for Mobile Devices Trainer name Date.
Developing J2ME Applications Mobile and Wireless Networks.
Cosc 4730 Phone Programming in Java An Introduction.
Java 2 Micro Edition Mano Chen Senior Technical Consultant
Java 2 Platform, Micro Edition (J2ME) By Xiaorong Wang.
J2ME and WAP Technologies CSCI – Independent Study Fall 2002 Presented by: Kashif Syed.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
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.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Databases for Mobile Devices Introduction. Overview Different types of data storages Memory management Local database techniques.
Getting Started with JXTA for J2ME Advisor : Dr. Ching-Long Yeh Report : DI.2, 洪泰昌 ( ) Course: XML 文件管理.
@2011 Mihail L. Sichitiu1 Android Introduction Platform Overview.
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
Java Mobile Application sms,sim,mms and barcode application Presented by Ayedh(SIM and MMS) Asad(SMS and Barcode Application)
Mobile Applications with Java ME & BlackBerry. Overview Java ME –Networking –Databases Java ME and the BlackBerry –The BlackBerry wireless device –Converting.
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:
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
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
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.
Martin Schmidt / The Silent Revolution Mobile Java.
BlackBerry Persistent Storage Models Persistent Storage APIs and Record Management System.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Java 2 Micro Edition The Connected, Limited Device Configuration.
CSCI1600: Embedded and Real Time Software Lecture 18: Real Time Languages Steven Reiss, Fall 2015.
MIDP Database Programming Using RMS: Jingwu He Csc 3360.
1 Android Workshop Platform Overview. 2 What is Android?  Android is a software stack for mobile devices that includes an operating system, middleware.
Enhanced mobile services in Java enabled phones Björn Hjelt Sonera zed ltd Supervisor: Professor Jorma Jormakka.
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.
The Java Platform Micro Edition Java ME
Java- I/O, SMS etc N Amanquah.
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
Introduction to the CVM and the Timesys RI
MOBILE DEVICE OPERATING SYSTEM
Wireless Instant Messaging Using J2ME
Introduction Enosis Learning.
By Jeff Heaton An Overview of J2ME By Jeff Heaton
Introduction Enosis Learning.
Units with – James tedder
Units with – James tedder
Java for Mobile Devices
Presentation transcript:

Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 8 CDC andJ2ME Rob Pooley

Programming Handheld and Mobile devices 2 Mobile Information Device Profile The first J2ME profile Targets devices implementing CLDC Profile addresses: –Display toolkit, user input methods –Persistent data storage –Messaging( SMS, , etc), security and networking over wireless network connection –Sun provides Reference Implementation FCS in September 2000

Programming Handheld and Mobile devices 3 Related Technologies: Java Card™ Technology Specifies minimized subset of Java technology for GSM SIM cards, smart cards, Java rings, and other extremely constrained devices Key benefits versus non- Java smart cards –Multiple applications per card –Post-issuance updates to apps on card

Programming Handheld and Mobile devices 4 Related Technologies: EmbeddedJava™ Technology EmbeddedJava. technology is a program from Sun supporting development of dedicated-function embedded devices for a wide range of end uses EmbeddedJava technology gives device manufacturers the ability to: –Configure the Java platform to leave out unneeded classes and VM features –Minimize resource requirements and cost for a deeply-embedded device –Optimize for devices with no GUI and intermittent (at best) networking –Keep APIs for their devices private

Programming Handheld and Mobile devices 5 J2ME™: Connected Device Configuration Connected Device Configuration (CDC) –Targeted for devices that have 2 MB or more total available memory –Memory dedicated to J2ME environment –More than 2MB ROM/Flash –More than 512 KB RAM –Network connectivity –Full Java 2 Virtual Machine specification

Programming Handheld and Mobile devices 6 Example J2ME™ CDC Uses Wireless communicators High-end PDAs TV set-top boxes Gateways Automotive entertainment and navigation systems Telecomm/Networking Equipment Industrial Controllers

Programming Handheld and Mobile devices 7 What Is CVM? Basis for J2ME CDC and profiles –Large VMs for desktops/servers don.t scale well to devices –Static and dynamic memory footprint too big –Not embeddable, ROMable, not portable –Implicit assumption of virtual memory –Native stack use, address range reservation –Implicit assumption of process model Global variables,.system threads.

Programming Handheld and Mobile devices 8 CVM features Good JVM features Device friendliness. Easily re-targetable Narrow porting interface Almost entirely in C (except dynamic compiler) ~256KB with JNI, reflection, verification,. CVM supports all Java 2 Platform, version 1.3, VM features and libraries for security, weak references, JNI, RMI and JVMDI CVM allows devices to map Java threads directly to native threads. Can run Java classes out of ROM Contains a precise memory system with advanced Garbage Collection features: Small average GC pause times Pluggable Garbage Collectors Full separation of VM from memory system

Programming Handheld and Mobile devices 9 J2ME Profiles Mobile Information Device Profile (MIDP) –Profile for wireless devices implementing CLDC J2ME Foundation Profile –Profile for non-GUI networked devices implementing CDC J2ME Personal Basis, Personal, RMI Profiles –Basic graphics, next generation PersonalJava environment, and RMI support for CDC & Foundation Profile based devices

Programming Handheld and Mobile devices 10 CDC APIs Defines minimum set of APIs for Java VM support –java.lang.VM system classes (Object, Thread, etc.) –java.util.Underlying utilities –java.net.UDP Datagram and File URL –java.io.File –java.text.I18n support for Java VM error messages –java.security.Fine grain security and encryption for object serialization

Programming Handheld and Mobile devices 11 CVM Sizes Today CVM only –Static ROM + RAM req.= 258 KB Natives only –Static ROM + RAM req.= 124 KB Porting layer only –Static ROM + RAM req.= 28 KB CVM+natives+porting_layer –Static ROM + RAM req.= 410 KB

Programming Handheld and Mobile devices 12 Foundation Profile APIs Defines core set of Java platform functionality –No GUI –Subset of JDK 1.3 Completes full functionality from CDC –java.lang.Rounds out full java.lang.*(Compiler, UnknownError) –java.util.Adds full zip support, Timer, etc. –java.net.Adds TCP Socket and HTTP –java.io.Rounds out full java.io.* (Readers and Writers) –java.text.Full I18n (Annotation, Collator, Iterators, etc.) –java.security.Adds Code Signing and Certificates

Programming Handheld and Mobile devices 13 CVM Sizes with Foundation Profile APIs CDC Java libraries (ROMized) –Static ROM + RAM req.= 1011 KB Foundation Java libraries (ROMized) –Static ROM + RAM req.= 1564 KB CDC TOTAL (CVM+natives+porting+libraries) –Static ROM + RAM req.= 1421 KB Java libraries + natives for Foundation Profile –Static ROM + RAM req = 553 KB Foundation TOTAL (CVM+natives+porting+libraries) –Static ROM + RAM req.= 1974 KB

Programming Handheld and Mobile devices 14 Header files /* * RMSGameScores.java * Copyright (c) 2000 Sun Microsystems, Inc. All Rights Reserved. * * Author: Srikanth Raju * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. */ import javax.microedition.midlet.*; import javax.microedition.rms.*; import java.io.DataOutputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.EOFException;

Programming Handheld and Mobile devices 15 Final example /** * A class used for storing and showing game scores. */ public class RMSGameScores extends MIDlet implements RecordFilter, RecordComparator { /* * The RecordStore used for storing the game scores. */ private RecordStore recordStore = null; /* * The player name to use when filtering. */ public static String playerNameFilter = null; /** * The constuctor opens the underlying record store, * creating it if necessary. */ public RMSGameScores() { // Create a new record store for this example try { recordStore = RecordStore.openRecordStore( "scores", true ); } catch ( RecordStoreException rse ) { System.out.println( "Record Store Exception in the ctor." + rse ); rse.printStackTrace(); }

Programming Handheld and Mobile devices 16 Final example /** * startApp() */ public void startApp() throws MIDletStateChangeException { RMSGameScores rmsgs = new RMSGameScores(); rmsgs.addScore( 100, "Alice" ); rmsgs.addScore( 120, "Bill" ); rmsgs.addScore( 80, "Candice" ); rmsgs.addScore( 40, "Dean" ); rmsgs.addScore( 200, "Ethel" ); rmsgs.addScore( 110, "Farnsworth" ); rmsgs.addScore( 220, "Alice" ); RMSGameScores.playerNameFilter = "Alice"; System.out.println( "Print all scores followed by Scores for Farnsworth" ); rmsgs.printScores(); } /* * Part of the RecordFilter interface. */ public boolean matches( byte[] candidate ) throws IllegalArgumentException { // If no filter set, nothing can match it. if ( this.playerNameFilter == null ) { return false; } ByteArrayInputStream bais = new ByteArrayInputStream( candidate ); DataInputStream inputStream = new DataInputStream( bais ); String name = null; try { int score = inputStream.readInt(); name = inputStream.readUTF(); } catch ( EOFException eofe ) { System.out.println(eofe); eofe.printStackTrace(); } catch ( IOException eofe ) { System.out.println( eofe ); eofe.printStackTrace(); } return( this.playerNameFilter.equals( name )); }

Programming Handheld and Mobile devices 17 Final example /* * Part of the RecordComparator interface. */ public int compare(byte[] rec1, byte[] rec2) { // Construct DataInputStreams for extracting the scores from // the records. ByteArrayInputStream bais1 = new ByteArrayInputStream( rec1 ); DataInputStream inputStream1 = new DataInputStream( bais1 ); ByteArrayInputStream bais2 = new ByteArrayInputStream( rec2 ); DataInputStream inputStream2 = new DataInputStream( bais2 ); int score1 = 0; int score2 = 0; try { // Extract the scores. score1 = inputStream1.readInt(); score2 = inputStream2.readInt(); } catch ( EOFException eofe ) { System.out.println( eofe ); eofe.printStackTrace(); } catch ( IOException eofe ) { System.out.println( eofe ); eofe.printStackTrace(); } // Sort by score if ( score1 > score2 ) { return RecordComparator.FOLLOWS; } else if ( score1 < score2 ) { return RecordComparator.PRECEDES; } else { return RecordComparator.EQUIVALENT; } /** * Add a new score to the storage. * score the score to store. playerName the name of the play achieving this score. */ public void addScore( int score, String playerName ) { // Each score is stored in a separate record, formatted with // the score, followed by the player name. ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream outputStream = new DataOutputStream( baos ); try { // Push the score into a byte array. outputStream.writeInt( score ); // Then push the player name. outputStream.writeUTF( playerName ); } catch ( IOException ioe ) { System.out.println( ioe ); ioe.printStackTrace(); } // Extract the byte array byte[] b = baos.toByteArray(); try { // Add it to the record store recordStore.addRecord( b, 0, b.length ); } catch ( RecordStoreException rse ) { System.out.println( rse ); rse.printStackTrace(); }

Programming Handheld and Mobile devices 18 Final example /** * A helper method for the printScores methods. */ private void printScoresHelper( RecordEnumeration re ) { try { while( re.hasNextElement() ) { int id = re.nextRecordId(); ByteArrayInputStream bais = new ByteArrayInputStream( recordStore.getRecord( id ) ); DataInputStream inputStream = new DataInputStream( bais ); try { int score = inputStream.readInt( ); String playerName = inputStream.readUTF(); System.out.println( playerName + " = " + score ); } catch ( EOFException eofe ) { System.out.println( eofe ); eofe.printStackTrace(); } catch ( RecordStoreException rse ) { System.out.println( rse ); rse.printStackTrace(); } catch ( IOException ioe ) { System.out.println( ioe ); ioe.printStackTrace(); } /** * This method prints all of the scores sorted by game score. */ public void printScores() { try { // Enumerate the records using the comparator implemented // above to sort by game score. // No RecordFilter here. All records in the RecordStore RecordEnumeration re = recordStore.enumerateRecords( null, this, true ); // Print all scores System.out.println( "Print all scores..." ); printScoresHelper( re ); // Enumerate records respecting a RecordFilter re = recordStore.enumerateRecords( this, this, true ); //Print scores for Farnsworth System.out.println( "Print scores for : " + this.playerNameFilter ); printScoresHelper( re ); } catch ( RecordStoreException rse ) { System.out.println( rse ); rse.printStackTrace(); }

Programming Handheld and Mobile devices 19 Final example /** * pauseApp() */ public void pauseApp() { System.out.println( "pauseApp()"); } /** * destroyApp() * * This closes our open RecordStore when we are destroyed. cond true if this is an unconditional destroy * false if it is not * (ignored here and treated as unconditional) */ public void destroyApp( boolean cond ) { System.out.println( "destroyApp( )"); try { if( recordStore != null ) recordStore.closeRecordStore(); } catch ( Exception ignore ) { // ignore this }