wireless programminag with j2me

410 304 0
wireless programminag with j2me

Đ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

Wireless Programming with J2ME Dreamtech Software Team A line-by-line look inside 6 professional-grade mobile applications *85555-BAAIAa ,!7IA7G4-feiifh!:p;o;t;T;T www.hungryminds.com ISBN 0-7645-4885-9 Reader Level Intermediate to Advanced Shelving Category Programming Dreamtech Software India, Inc., is a leading provider of corporate software solutions. Based in New Delhi, India, the Dreamtech software team has more than 50 years of combined software engineering experience. Take an In-Depth Look at 6 Professional-Grade Mobile Applications • Online testing engine for Palm OS devices • Online ordering system for cell phones and pagers • MP3 player for Pocket PCs • Peer-to-peer search application for Palm OS devices • Mobile Web services (weather, movie ticket ordering, news) for cell phones • Target practice game for Palm OS devices • Plus CLDC implementation, MIDP-MIDlet implementation, and XML parsing case studies and guidance on converting existing applications into J2ME All software tested at the Dreamtech Software Research Lab Create Tomorrow’s Mobile Applications Today In this unique guide, a crack team of software engineers delivers the programming solutions and source code you need to jump-start a wide range of mobile application projects with Java 2 Micro Edition. Using flow charts and line-by-line analysis of six professional-quality applications, they show you how to solve for typical J2ME programming challenges — and create your own applications using CLDC, MIDP, XML, and other cutting-edge technologies. $49.99 US $74.99 CANADA £39.99 UK incl. VAT Wireless Programming with J2ME 5 , 7 0 0 + l i n e s o f s o u r c e c o d e o n C D - R O M ! c o d e o n C D - R O M ! 5 , 7 0 0 + l i n e s o f s o u r c e Wireless Programming with J2ME Dreamtech Software Team CD-ROM Includes: 6 professional-quality appli- cations and 3 topical case studies, complete with over 5,700 lines of source code Java 2 Software Development Kit Standard Edition version 1.3 for Windows Java 2 Platform, Micro Edition, Wireless Toolkit 1.0.1 Forte for Java, release 2.0, Community Edition for All Platforms Tomcat JavaServer Pages Implementation Server and kXML ™ ™ ™ 4885-9 cover 11/14/01 2:41 PM Page 1 www.traintelco.com Wireless Programming with J2ME™ www.traintelco.com www.traintelco.com Wireless Programming with J2ME™ Cracking the Code™ Dreamtech Software Team Best-Selling Books • Digital Downloads • e-Books • Answer Networks • e-Newsletters • Branded Web Sites • e-Learning New York, NY  Cleveland, OH  Indianapolis, IN www.traintelco.com Wireless Programming with J2ME™: Cracking the Code™ Published by Hungry Minds, Inc. 909 Third Avenue New York, NY 10022 www.hungryminds.com Copyright © 2002 Hungry Minds, Inc. All rights reserved. No part of this book, including interior design, cover design, and icons, may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording, or otherwise) without the prior written permission of the publisher. Library of Congress Control Number: 2001093843 ISBN: 0-7645-4885-9 Printed in the United States of America 10 9 8 7 6 5 4 3 2 1 1B/QR/QS/QS/IN Distributed in the United States by Hungry Minds, Inc. Distributed by CDG Books Canada Inc. for Canada; by Transworld Publishers Limited in the United Kingdom; by IDG Norge Books for Norway; by IDG Sweden Books for Sweden; by IDG Books Australia Publishing Corporation Pty. Ltd. for Australia and New Zealand; by TransQuest Publishers Pte Ltd. for Singapore, Malaysia, Thailand, Indonesia, and Hong Kong; by Gotop Information Inc. for Taiwan; by ICG Muse, Inc. for Japan; by Intersoft for South Africa; by Eyrolles for France; by International Thomson Publishing for Germany, Austria, and Switzerland; by Distribuidora Cuspide for Argentina; by LR International for Brazil; by Galileo Libros for Chile; by Ediciones ZETA S.C.R. Ltda. for Peru; by WS Computer Publishing Corporation, Inc., for the Philippines; by Contemporanea de Ediciones for Venezuela; by Express Computer Distributors for the Caribbean and West Indies; by Micronesia Media Distributor, Inc. for Micronesia; by Chips Computadoras S.A. de C.V. for Mexico; by Editorial Norma de Panama S.A. for Panama; by American Bookshops for Finland. For general information on Hungry Minds’ products and services please contact our Customer Care department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993 or fax 317-572-4002. For sales inquiries and reseller information, including discounts, premium and bulk quantity sales, and foreign-language translations, please contact our Customer Care department at 800-434-3422, fax 317-572-4002 or write to Hungry Minds, Inc., Attn: Customer Care Department, 10475 Crosspoint Boulevard, Indianapolis, IN 46256. For information on licensing foreign or domestic rights, please contact our Sub-Rights Customer Care department at 212-884- 5000. For information on using Hungry Minds’ products and services in the classroom or for ordering examination copies, please contact our Educational Sales department at 800-434-2086 or fax 317-572-4005. For press review copies, author interviews, or other publicity information, please contact our Public Relations department at 317-572-3168 or fax 317-572-4168. For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 978-750-4470. LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND AUTHOR HAVE USED THEIR BEST EFFORTS IN PREPARING THIS BOOK. THE PUBLISHER AND AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS BOOK AND SPECIFICALLY DISCLAIM ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. THERE ARE NO WARRANTIES WHICH EXTEND BEYOND THE DESCRIPTIONS CONTAINED IN THIS PARAGRAPH. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES REPRESENTATIVES OR WRITTEN SALES MATERIALS. THE ACCURACY AND COMPLETENESS OF THE INFORMATION PROVIDED HEREIN AND THE OPINIONS STATED HEREIN ARE NOT GUARANTEED OR WARRANTED TO PRODUCE ANY PARTICULAR RESULTS, AND THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY INDIVIDUAL. NEITHER THE PUBLISHER NOR AUTHOR SHALL BE LIABLE FOR ANY LOSS OF PROFIT OR ANY OTHER COMMERCIAL DAMAGES, INCLUDING BUT NOT LIMITED TO SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR OTHER DAMAGES. Trademarks: Hungry Minds, the Hungry Minds logo, and Cracking the Code are trademarks or registered trademarks of Hungry Minds, Inc. in the United States and other countries and may not be used without written permission. Java, Forte, NetBeans and all trademarks and logos based on Java, Forte, and NetBeans are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All other trademarks are the property of their respective owners. Hungry Minds, Inc., is not associated with any product or vendor mentioned in this book. is a trademark of Hungry Minds, Inc. www.traintelco.com Credits Acquisitions Editor Chris Webb Project Editor Chandani Thapa Technical Editor Dr. K.V.K.K. Prasad Media Development Specialist Angela Denny Permissions Editor Laura Moss Media Development Manager Laura Carpenter VanWinkle Project Coordinator Nancee Reeves Cover Design Anthony Bunyan Proofreader Anne Owen Indexer Johnna VanHoose Dinse Cover Vault door image used courtesy of Brown Safe Manufacturing www.BrownSafe.com www.traintelco.com Dreamtech Software India, Inc., Team dreamtech@mantraonline.com www.dreamtechsoftware.com Dreamtech Software India, Inc., is a leading provider of corporate software solutions. Based in New Delhi, India, the company is a successful pioneer of innovative solutions in e-learning technologies. Dreamtech’s developers have more than 50 years of combined software-engineering experience in areas such as Java, wireless applications, XML, voice-based solutions, .NET, COM/COM+ technologies, distributed computing, DirectX, Windows Media technologies, and security solutions. About the Authors Lead Author Team Vikas Gupta, Co-founder and President. Vikas holds a B.E. in electronics, with a postgraduate diploma in sales and marketing and in publishing and printing studies. Actively engaged in developing and designing new technologies in wireless applications, e-learning, and other cutting-edge areas, he is also the Managing Director of IDG Books India (P) Ltd. Avnish Dass, Co-founder and CEO. Avnish is a talented and seasoned programmer who has 15 years of experience in systems and application/database programming. Avnish has developed security systems, antivirus programs, wireless and communication technologies, and ERP systems. Yashraj Chauhan, Sr. Software Developer. Yashraj has an advanced diploma in software development from IBM, with more than three years of experience in Java, XML, and C++, and is pursuing his Masters in computer science. Other Contributors Pankaj Kumar, Deepak Sharma, Gaurav Malhotra, Anil Kumar Singh, Bill Ray, a team of programmers of Dreamtech Software India, Inc. They contributed to the development of software in this book. www.traintelco.com Acknowledgments We acknowledge the contributions of the following people for their support in making this book possible: John Kilcullen for sharing his dream and providing the vision for making this project a reality. Mike Violano and Joe Wikert for believing in us. V.K. Rajan and Priti for their immense help in coordinating various activities throughout this project. www.traintelco.com To our parents and family and beloved country, India, for providing an excellent environment for nurturing and creating world-class IT talent. www.traintelco.com Preface Wireless devices are new entrants in the information technology arena. As wireless devices are compact and easy to handle, the focus of Information technology is rapidly shifting from PCs to PDAs, cellular phones, and pagers. The market for these devices has undergone a tremendous growth over the past few years. These devices are becoming increasingly sophisticated in response to the demand for using them to access the Net as well as computing devices. Moreover, these devices are paving the way for new business strategies. Sun Microsystems fulfilled the aspirations of the Java Community by launching J2ME (Java 2 Micro Edition), which gave Java an edge over other programming tools in its performance on wireless devices. It was first introduced at the Java One Conference in 1999. The J2ME has two “design centers.” Thus, this platform has two configurations and these are CLDC (Connected Limited Device Configuration) and CDC (Connected Device Configuration). This has to be kept in mind while talking about J2ME. With an approach that is based on configurations and profiles, J2ME offers flexibility to the developer, which is of great significance for extremely diverse handheld and wireless devices. This approach makes it possible to provide as much functionality as the device has the potential to support. Added to this are the usual benefits of Java, such as portability across platforms, security, and the object–oriented character. This is why Java is predicted to be the most preferred language for the modern computing devices. It may well be said that J2ME is still in the early stages of development. Two configurations have become available, but only a few of the proposed profiles are available as of now. This situation is bound to change as soon as the Micro Edition platform becomes more mature. Consequently, its use is also expected to increase considerably. Many leading companies have started releasing Java-enabled devices. This means that you can download Java applications even on your mobile phones and run them offline. What this Book Covers This book is based on the unique concept of cracking the code and mastering the technology. The technologies covered are J2ME (Java 2 Micro Edition) version 1.0.2 and the applications are also tested on version 1.0.3 Beta. The book is loaded with code, keeping theory to a minimum. All the applications for which the source code is given have been fully tested at Dreamtech Software Research Lab. The source code provided in the book is based on commercial applications developed by the software development company Dreamtech Software India Inc. Each program of an application is explained in a very detailed manner to provide the reader clear insight into the implementation of the technology in a real-world situation. At the end of the book, reference links are given so that the inquisitive reader can further explore the new developments that are taking place. As J2ME is a new platform, not many books are available on this topic. There are some books that introduce you to the theory part of J2ME. This book, being a part of the Cracking the Code series, focuses more on developing applications. Here, only a brief introduction to J2ME has been given, with the major part of the book devoted to writing commercial-quality code. This is clear from the fact that, out of the 12 chapters in this book, six are actually projects. Another two are almost fully devoted to case studies. The idea here is to familiarize working professionals with the J2ME code. You can also see the practical differences between the Standard Edition and the Micro Edition by going through these projects and case studies. It is assumed that the reader has a reasonable command over the Java language and has some experience in programming. www.traintelco.com [...]... 382 www.traintelco.com www.traintelco.com Chapter 1 An Overview of J2ME This chapter presents the basics of J2ME and serves to enlighten the reader on the steps involved in programming with J2ME It also provides the groundwork necessary for developing applications J2ME has been compared with J2SE, and so some background is provided on J2ME virtual machines We also mention, albeit not in detail, Java... 1: An Overview of J2ME Configuration) and CDC (Connected Device Configuration) You need to keep this fact in mind while talking about J2ME Whenever you’re programming for a mobile phone, you are as much within the fold of the J2ME as you are if you’re programming for a set-top box with almost as much computing power as a desktop system But it is true that J2ME is more associated with small devices... considering that it’s soon to be formally merged with J2ME as the Personal Profile www.traintelco.com 10 Chapter 1: An Overview of J2ME The profiles that are under development at present and may soon be available are as follows: ♦ Personal Profile ♦ PDA Profile ♦ RMI Profile Getting Set to Program with J2ME What are the prerequisites for taking up programming with J2ME? Where do we begin? We answer these questions... applications to J2ME, as explained in the CDC and Foundation Profile porting guide Therefore, PersonalJava can be considered a part of the J2ME platform If you are going to work with MIDP, you can make the development process somewhat easier by downloading and installing the J2ME Wireless Toolkit, available from Sun’s site as a free download You can use it as is, or you can integrate it with Forte for... technologies is not mandatory for a J2ME programmer, but it serves to clarify the role of J2ME in the world of wireless programming And because some of these technologies may be absorbed (in a modified form) into the J2ME fold in the future, many programmers working with them may choose to shift to the micro edition Besides, there is the fact that many of the concepts used in J2ME are the same as those used... APIs fully The fifth chapter is on J2ME and contains what is relevant to programming with J2ME It deals with XML parsing XML parsing is used in almost all the projects in the book After the introduction, the reader is told about one of several available parser packages, namely kXML Needless to say, this example of XML parsing is provided in the form of functioning code With the sixth chapter begins a... required This is understandable because most of theses devices are mobile and use wireless communication www.traintelco.com www.traintelco.com Contents Preface .viii Chapter 1: An Overview of J2ME 1 Introduction 1 What J2ME is about 1 What J2ME offers 2 J2ME Virtual Machines 3 The K Virtual Machine (KVM) 3... 9 Other profiles 9 Getting Set to Program with J2ME 10 Our First J2ME Application 10 RelatedJava Technologies 12 PersonalJava 12 Java Card 13 Summary 15 Chapter 2: Programming Techniques for J2ME 16 Constraints of J2ME Targeted Devices 16 Limited processor speed ... of the J2ME code, we present here the first application of the book: a Hello application We are not going to explain the code in Listing 1-1, because right now we are still acquainting ourselves with CLDC and MIDP, which are, respectively, the configuration and the profile used in this application Just take a look at the following code and familiarize yourself with J2ME: Listing 1-1: HelloFromJ2ME.java... Our first application in J2ME */ public class HelloFromJ2ME extends MIDlet implements CommandListener { www.traintelco.com Chapter 1: An Overview of J2ME 11 // Class String is from java.io, which is in CLDC String s = "Hello From J2ME" ; private Command quit; // The Quit button private Display ourDisplay; // Declaring the display private Form ourForm = null; public HelloFromJ2ME() { ourDisplay = Display.getDisplay(this); . VAT Wireless Programming with J2ME 5 , 7 0 0 + l i n e s o f s o u r c e c o d e o n C D - R O M ! c o d e o n C D - R O M ! 5 , 7 0 0 + l i n e s o f s o u r c e Wireless Programming with J2ME Dreamtech Software Team CD-ROM. cover 11/14/01 2:41 PM Page 1 www.traintelco.com Wireless Programming with J2ME www.traintelco.com www.traintelco.com Wireless Programming with J2ME Cracking the Code™ Dreamtech Software Team Best-Selling. mobile and use wireless communication. www.traintelco.com www.traintelco.com Contents Preface viii Chapter 1: An Overview of J2ME 1 Introduction 1 What J2ME is about 1 What J2ME offers 2 J2ME Virtual

Ngày đăng: 27/10/2014, 01:05

Từ khóa liên quan

Mục lục

  • Wireless Programming with J2ME™

    • Front of Book

      • General Info

      • Credits

      • About Dreamtech Software

      • About the Authors

      • Acknowledgments

      • Dedication

      • Preface

        • What this Book Covers

        • How the Book Is Organized

        • Who Should Read this Book

        • Contents

        • Chapter 1: An Overview of J2ME

          • Introduction

            • What J2ME is about

            • What J2ME offers

            • J2ME Virtual Machines

              • The K Virtual Machine (KVM)

              • The C Virtual Machine (CVM)

              • Configurations

                • CLDC

                • CDC

                • Profiles

                  • Mobile Information Device Profile (MIDP)

                  • Foundation Profile

                  • Other profiles

                  • Getting Set to Program with J2ME

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

Tài liệu liên quan