Core J2ME™ Technology & MIDP phần 1 pot

56 787 1
Core J2ME™ Technology & MIDP phần 1 pot

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Brought to you by ownSky! Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com • Table of Contents Core J2ME™ Technology & MIDP By John W. Muchow Publisher : Prentice Hall PTR Pub Date : December 21, 2001 ISBN : 0-13-066911-3 Pages : 737 The J2ME platform is designed for devices with limited memory, display, and processing power including cellular phones, PDAs, and pagers. Core J2ME Technology & MIDP covers everything you need to develop powerful applications for this rapidly expanding wireless market. Part I starts with an overview of J2ME, configurations, and profiles, before explaining in detail the Connected Limited Device Configuration (CLDC) and the Mobile Information Device Profile (MIDP). Muchow then walks you through creating a complete development environment-from downloading J2ME to troubleshooting. Part II details programming with MIDP, including exhaustive coverage of the MIDP programming interface, high-level and low-level user interface components, networking support, and persistent storage. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ii Table of Content Table of Content i Copyright vii Dedication viii Preface viii Who Is This Book For viii Focus of this Book ix Contents ix Acknowledgments xiii About the Author xiii Chapter 1. THE BASICS Of J2ME 1 Java Editions 1 Why J2ME? 2 Configurations 3 Profiles 3 Java Virtual Machines 4 Big Picture View of the Architecture 5 Compatibility between Java Editions 6 Putting all the Pieces Together 7 Chapter 2. CONNECTED, LIMITED DEVICE CONFIGURATION (CLDC) 8 Hardware Requirements 9 Software Requirements 9 The Java Virtual Machine Specification 9 Handling Security 11 Class File Verification 12 J2SE Inherited Classes 12 CLDC Specific Classes 16 K Virtual Machine 17 Chapter 3. MOBILE INFORMATION DEVICE PROFILE (MIDP) 18 Hardware and Software Requirements 18 MID Profile Architecture 19 The MIDlet Suite 20 Accessing JAR/JAD Attributes from a MIDlet 24 Chapter 4. DEVELOPMENT ENVIORNMENT 27 Download the Software 27 Install the Software 28 Command Line Development 33 Packaging a MIDlet 36 Running a MIDlet on an Emulator 39 Download MIDlet onto a Mobile Device 41 Project Management Using Java Packages 41 J2ME Wireless Toolkit 45 Download 46 Installation 46 Create a New Project 47 Configure the Project Settings 48 Write the Code and Build the Project 51 Using Java Packages 53 Locating the JAR and JAD Files 54 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com iii Configuring the Emulator 55 Toolkit Summary 56 Chapter 5. BASICS OF MIDLETS AND THE DISPLAY 57 MIDlet 57 MIDletStateChangeException 61 Display 66 Displayable 69 Chapter 6. EVENT HANDLING 72 The Big Picture 72 Command Objects 73 Item Objects 74 Command and CommandListener 75 Item and ItemStateListener 87 Chapter 7. HIGH-LEVEL USER INTERFACE: PART I 91 Screen 91 Form 93 Item 94 DateField 98 Gauge 104 StringItem 109 TextField 115 Choice and ChoiceGroup 123 Image and ImageItem 132 Chapter 8. HIGH-LEVEL USER INTERFACE: PART II 146 List 147 TextBox 157 Alert and AlertType 172 Ticker 180 Chapter 9. LOW-LEVEL USER INTERFACE 184 Canvas 184 Graphics 209 Chapter 10. CREATING A DISPLAYER MANAGER 253 Animation MIDlet 254 Display Manager API 257 Animating a Series of Images 260 Source Code 262 Chapter 11. RECORD MANAGEMENT SYSTEM (RMS) 271 Persistent Storage Through the Record Store 271 Navigating with RecordEnumeration 284 Sorting with RecordComparator 286 Searching with RecordFilter 303 Notification of Changes with RecordListener 316 Exception Handling 320 Chapter 12. TODO LIST EXAMPLE: PART I 322 Using the Todo List 322 Interface Design 325 Data Design 326 Application Logic 331 Source Code 333 Chapter 13. SCHEDULING TASKS 350 Timer 350 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com iv TimerTask 353 Example: Timer Template 354 Example: Todo List MIDlet Part II—Delay Timer 358 Example: Animation with Timer/TimerTask 361 Chapter 14. GENERIC CONNECTION FRAMEWORK 369 Connection Hierarchy 369 HTTP Connection 371 Chapter 15. MIDP FOR THE PALM OS 440 Device Requirements 441 Download 442 Installation 442 MIDlets 444 Configuring Preferences 450 Example: keyCodes and gameActions 455 Appendix A. Over the Air User Initiated Provisioning Recommended Practice 468 General Information 468 Device (Client) 469 MIDlet Suite Upgrade 473 MIDlet Suite Removal 473 Server 473 WAP 475 Appendix B. CLDC API 477 java.io 480 ByteArrayInputStream 480 ByteArrayOutputStream 481 DataInput 481 DataInputStream 482 DataOutput 483 DataOutputStream 484 EOFException 484 InputStream 485 InputStreamReader 485 InterruptedIOException 486 IOException 486 OutputStream 486 OutputStreamWriter 487 PrintStream 487 Reader 488 UnsupportedEncodingException 489 UTFDataFormatException 489 Writer 490 java.lang 490 ArithmeticException 491 ArrayIndexOutOfBoundsException 491 ArrayStoreException 491 Boolean 492 Byte 492 Character 493 Class 494 ClassCastException 494 ClassNotFoundException 494 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com v Error 495 Exception 495 IllegalAccessException 495 IllegalArgumentException 496 IllegalMonitorStateException 496 IllegalThreadStateException 496 IndexOutOfBoundsException 496 InstantiationException 497 Integer 497 InterruptedException 498 Long 498 Math 499 NegativeArraySizeException 499 NullPointerException 500 NumberFormatException 500 Object 500 OutOfMemoryError 501 Runnable 501 Runtime 501 RuntimeException 502 SecurityException 502 Short 502 String 503 StringBuffer 505 StringIndexOutOfBoundsException 506 System 506 Thread 507 Throwable 508 VirtualMachineError 508 java.util 509 Calendar 509 Date 511 EmptyStackException 511 Enumeration 511 Hashtable 512 NoSuchElementException 512 Random 513 Stack 513 TimeZone 514 Vector 514 javax.microedition.io 515 Connection 516 ConnectionNotFoundException 516 Connector 516 ContentConnection 517 Datagram 517 DatagramConnection 518 InputConnection 518 OutputConnection 519 StreamConnection 519 StreamConnectionNotifier 519 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com vi Appendix C. MIDP API 520 Alert: javax.microedition.lcdui.Alert 522 AlertType: javax.microedition.lcdui.AlertType 522 Canvas: javax.microedition.lcdui.Canvas 523 Choice: javax.microedition.lcdui.Choice 524 ChoiceGroup: javax.microedition.lcdui.ChoiceGroup 524 Command: javax.microedition.lcdui.Command 525 CommandListener: javax.microedition.lcdui.CommandListener 526 DateField: javax.microedition.lcdui.DateField 526 Display: javax.microedition.lcdui.Display 527 Displayable: javax.microedition.lcdui.Displayable 527 Font: javax.microedition.lcdui.Font 528 Form: javax.microedition.lcdui.Form 528 Gauge: javax.microedition.lcdui.Gauge 529 Graphics: javax.microedition.lcdui.Graphics 529 HttpConnection: javax.microedition.io.HttpConnection 531 Image: javax.microedition.lcdui.Image 536 ImageItem: javax.microedition.lcdui.ImageItem 536 Item: javax.microedition.lcdui.Item 537 ItemStateListener: javax.microedition.lcdui.ItemStateListener 537 List: javax.microedition.lcdui.List 538 MIDlet: javax.microedition.midlet.MIDlet 539 MIDletStateChangeException: javax.microedition.midlet.MIDletStateChangeException 539 RecordComparator: javax.microedition.rms.RecordComparator 539 RecordEnumeration: javax.microedition.rms.RecordEnumeration 540 RecordFilter: javax.microedition.rms.RecordFilter 540 RecordListener: javax.microedition.rms.RecordListener 541 RecordStore: javax.microedition.rms.RecordStore 541 Record Store Exceptions 542 Screen: javax.microedition.lcdui.Screen 543 StringItem: javax.microedition.lcdui.StringItem 543 TextBox: javax.microedition.lcdui.TextBox 543 TextField: javax.microedition.lcdui.TextField 544 Ticker: javax.microedition.lcdui.Ticker 545 Timer: java.util.Timer 546 TimerTask: java.util.TimerTask 546 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com vii Copyright A CIP catalog record for this book can be obtained from the Library of Congress. © 2002 Sun Microsystems, Inc.— Printed in the United States of America 901 San Antonio Road, Palo Alto, California 94303-4900 U.S.A. All rights reserved. This product and related documentation are protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation. No part of this product or related documentation may be reproduced in any form or by any means without prior written authorization of Sun and its licensors, if any. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (e)(1)(ii) and FAR 52.227-19. The products described may be protected by one or more U.S. patents, foreign patents, or pending applications. TRADEMARKS—HotJava, Java, Java Development Kit, Solaris, SPARC, SunOS, and Sunsoft are trademarks of Sun Microsystems, Inc. All other products or services mentioned in this book are trademarks or service marks of their respective companies or organizations. The publisher offers discounts on this book when ordered in bulk quantities. For more information, contact Corporate Sales Department, Prentice Hall PTR, One Lake Street, Upper Saddle River, NJ 07458. Phone 800-382- 3419: FAX: 201-236-7141. E-mail: corpsales@prenhall.com. Editorial/Production Supervison: Pine Tree Composition Acquisitions Editor: Gregory G. Doench Editorial Assistant: Brandt Kenna Cover Design Director: Jerry Votta Cover Designer: Nina Scuderi Art Director: Gail Cocker-Bogusz Manufacturing Manager: Alexis Heydt-Long Marketing Manager: Debby vanDijk Project Coordinator: Anne R. Garcia Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com viii Sun Microsystems Press Publisher: Michael Llwyd Alread 10 9 8 7 6 5 4 3 2 Sun Microsystems Press A Prentice Hall Title Dedication This book is dedicated, from the heart, to my Mom and Dad Preface It is estimated that in Japan alone over 20 million Java 2 Micro Edition (J2ME) enabled mobile phones were manufactured in 2001. The opportunity for those interested in writing for the J2ME platform speaks for itself. With its support for a broad range of devices and portability across platforms, acceptance among manufacturers and service providers has been astounding. The focus of this book is on application development using the Mobile Information Device Profile (MIDP) and Connected, Limited Device Configuration (CLDC). Together, these application programming interfaces (API's) form a complete J2ME development toolkit for wireless devices including: mobile phones, pagers and personal organizers. Who Is This Book For As a developer at heart, I have often sought a book that covered "all I need to know" to get started with a technology that was of interest. Instead I found myself putting together pieces and parts based on information from various websites, newsgroups, how-to articles, and the like. There was never one definitive guide covering everything: where to find the software, how to install and configure my computer, and learning to write applications from the ground up. Most important of all, there always seemed to be gap between what information I could find and what appeared to be available as part of the specification describing the technology. I hope this book is as close to one-stop shopping as you will find for learning and developing applications for J2ME and the Mobile Information Device Profile. It has what I feel are the essentials to get up and running, everything from downloading and installing the software to writing applications from simple to comprehensive. The entire programming interface is covered in a logical step-by-step manner, leaving no stone unturned. It also includes a quick reference guide for both MIDP and CLDC. Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com ix Although this book takes a step-by-step approach to teaching application development with MIDP, the assumption is made that the reader will have experience as a software developer. Further, as J2ME is a subset of Java 2 Standard Edition, a background in Java programming is essential to make the most of this book. Focus of this Book With many years of experience as a developer, and an extensive background in technical training, I've discovered that most people (myself included) learn best by example. With that in mind, this book provides an abundance of source code, with the intention of presenting solutions to real-world programming issues. With over 70 examples, you'll have an excellent base of code to build upon: • Creating a "clipboard" to share data among components • Using streams to read and write persistent storage • Searching and sorting records in persistent storage • Low-level event handling • Primitive drawing operations (arcs, rectangles, text, etc.) • Creating simple animations • Scheduling timers • Creating a client request and interpreting a server response using HTTP • How and when to use HTTP request methods GET and POST • Managing sessions with a Java Servlet through cookies and URL-rewriting • Using a thread to download network data in the background • Download and view files and images • Many additional examples . . . Contents This book is divided into three sections: Part I: Introduction to J2ME, CLDC, and MIDP We begin with an overview of Java 2 Micro Edition. This includes information about the architecture of J2ME and how configurations and profiles make it possible for this micro version of Java to support devices with an exceptionally wide range of capabilities. Also included are step-by-step instructions for installing the required software and configuring your computer to develop J2ME applications (MIDlets). Part II: Programming with MIDP Here you will find the bulk of information about programming with the MID Profile. Presented in a tutorial fashion, we cover each aspect of the application programming interface. For each topic there is Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com [...]... memory, display and processing power Note In December of 19 98, Sun introduced the name "Java 2" (J2) to coincide with the release of Java 1. 2 This new naming convention applies to all editions of Java, Standard Edition (J2SE), Enterprise Edition (J2EE), and Micro Edition (J2ME) Figure 1 1 shows various Java editions Figure 1- 1 The various Java editions 1 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... Differences There are three main areas that distinguish the Java Language for CLDC versus that defined in the Java Language Specification [1] [1] The Java Language Specification by James Gosling, Bill Joy, and Guy L Steele Addison-Wesley, 19 96, ISBN 0-2 01- 634 51- 1 Floating Point Math Floating point math is inherently processor intensive Given this, and the fact that the majority of devices will not... persist when the device is shut off will need to be written to memory MIDP and MIDP Next Generation Sun's reference implementation of MIDP version 1. 0 is based on the following Java 18 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com Specification Request: http://jcp.org/jsr/detail/37.jsp Features being considered for MIDP "Next Generation" may include support for HTTPS, sockets and... pre-verified) is in the range of 10 kilobytes, with less than 10 0 bytes of heap space required This is a significant reduction over that of the "conventional" verifier available as part of J2SE J2SE Inherited Classes In an ideal world, a mobile device would run the same JVM as J2SE and have access to the entire J2SE core libraries, all 1+ megabytes That would be nice Now, back to our world 12 Simpo PDF Merge and... install an implementation of MIDP from a device manufacturer, or a third-party source, examples may look different than shown in the book, however, the functionality should be equivalent CoreJ2ME.com Website There is a companion website for this book: www.CoreJ2ME.com Here you will find the latest source code for the examples in this book, important notes about changes to the MIDP and/or CLDC specification... installed on the native operating system and is the foundation for MIDP Notice that MIDP applications have access to both the libraries of CLDC and MIDP OEM-specific (original equipment manufacturer) classes are provided by the manufacturer of the device Functionality added may include options such as the ability to answer incoming calls or to 19 Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com... This must be a PNG image file 21 Yes Yes No Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com MIDlet-Description MIDlet-Info-URL Text describing the MIDlet No URL that may have more information about the MIDlet and/or No the vendor Here is an example of a simple manifest file: MIDlet-Name: Todo List MIDlet-Version: 1. 0 MIDlet-Vendor: Core J2ME MIDlet -1: TodoList, /images/Todo.png,... TodoList, /images/Todo.png, Todo.TodoMIDlet MicroEdition-Profile: MIDP- 1. 0 MicroEdition-Configuration: CLDC -1. 0 Java Application Descriptor File (JAD) In addition to a JAR file, a JAD file may be available as part of the MIDlet suite to provide information about the MIDlet(s) within the JAR The rationale behind including a JAD file is as follows: 1 To provide information to the application manager about the... author of Core Servlets Unbeknown to you, your encouragement and enthusiasm early on were pivotal in my decision to write this book Now that it is complete, looking back I can honestly say the most enjoyable aspect was exploring the technology and creating the examples Which leads me to give thanks to the efforts of those at Sun Microsystems and members of the Expert Group for JSR 30 (CLDC) and 37 (MIDP) ... Unregistered Version - http://www.simpopdf.com Near the beginning of this chapter, when describing the hardware requirements, we stated the CLDC implementation requires approximately 16 0 kilobytes of memory to run the JVM and core libraries (12 8k and 32k, respectively) We are a few bytes short of the J2SE footprint Obviously, a few classes had to go Following is a list of the classes that made the cut System Classes . Date 511 EmptyStackException 511 Enumeration 511 Hashtable 512 NoSuchElementException 512 Random 513 Stack 513 TimeZone 514 Vector 514 javax.microedition.io 515 Connection 516 ConnectionNotFoundException. • Table of Contents Core J2ME™ Technology & MIDP By John W. Muchow Publisher : Prentice Hall PTR Pub Date : December 21, 20 01 ISBN : 0 -13 -066 911 -3 Pages : 737 The J2ME. I 91 Screen 91 Form 93 Item 94 DateField 98 Gauge 10 4 StringItem 10 9 TextField 11 5 Choice and ChoiceGroup 12 3 Image and ImageItem 13 2 Chapter 8. HIGH-LEVEL USER INTERFACE: PART II 14 6

Ngày đăng: 12/08/2014, 11:20

Từ khóa liên quan

Mục lục

  • Table of Content

  • Copyright

    • Dedication

    • Preface

      • Who Is This Book For

      • Focus of this Book

      • Contents

        • Part I: Introduction to J2ME, CLDC, and MIDP

        • Part II: Programming with MIDP

        • Part III: Appendices

        • Conventions Used in This Book

          • Table P-1. Form Class: javax.microedition.lcdui.Form

          • Table . MIDP Naming conventions

          • Mobile Information Device Emulators

          • CoreJ2ME.com Website

          • Acknowledgments

          • About the Author

          • Chapter 1. THE BASICS Of J2ME

            • Java Editions

                • Figure 1-1. The various Java editions

                • Why J2ME?

                • Configurations

                  • Connected Device Configuration (CDC)

                    • Connected, Limited Device Configuration (CLDC)

                    • Profiles

                    • Java Virtual Machines

                    • Big Picture View of the Architecture

                      • Generic Architecture

                        • Figure 1-2. "Generic" J2ME architecture

                        • Figure 1-3. MID Profile architecture

Tài liệu cùng người dùng

Tài liệu liên quan