How to install: java wireless toolkit (j2me 2

  -  

Get full access to lớn Wireless Java and 60K+ other titles, with miễn phí 10-day trial of O"Reilly.

Bạn đang xem: How to install: java wireless toolkit (j2me 2

There"s also live online events, interactive content, certification prep materials, & more.


This book is about wireless Java programming with the Java 2Platform, Micro Edition (J2ME). Sun Microsystems, Inc. IntroducedJ2ME at the JavaOne conference in June 1999 as the younger sibling ofboth the Java 2 Standard Edition (J2SE) và the Java 2 EnterpriseEdition (J2EE). At the time, distributed programming was taking theJava developer community by storm, so most of the participants at theshow were more interested in what J2EE had to lớn offer. However, overthe next two years, developers also realized that there wastremendous value in having small components running Java. Two yearslater, at the 2001 JavaOne conference, Sun devoted an entire trackfor individuals seeking khổng lồ master the once arcane J2ME. Luckily, youdon’t need lớn attend JavaOne to lớn learn about J2ME. Instead, thisbook will help you through the myriad details of understanding J2MEarchitecture & programming J2ME applications.

In this chapter, we will present an overview of J2ME’s primarycomponents, including virtual machines, configurations, and profiles.We’ll then present a few short examples of J2ME-enabledapplications to lớn whet your appetite and to show you how easy it is toget started with J2ME.


J2ME is a version of Sun Microsystems’ Java that is aimed atthe consumer and embedded devices market, which includes electroniccommodities such as cellular telephones, pagers, Personal DigitalAssistants (PDAs), set-top boxes, and other small devices. Since itsrelease, over 600 companies have joined the development effort,including large corporations such as Palm, Nokia, Motorola, & RIM.However, the direction that J2ME travels is not shrouded in secrecybehind closed corporate doors. Instead, development of J2ME ishandled through the JavaCommunity Process (JCP), which allowsanyone with an internet connection to get involved.

J2ME provides a complete phối of solutions for creatingstate-of-the-art networked applications for small devices. It alsopromises lớn enable device manufacturers, service providers, andapplication developers khổng lồ deploy new applications & services totheir customers. However, in doing so, it does not sacrifice some ofthe founding guidelines of Java, which have become increasinglyimportant these days, namely cross-platform compatibility andsecurity.


A series of Java virtual machines, each for use on different types ofsmall devices, each with different requirements

Various tools for deployment and device configuration


The first two components ảo diệu the J2ME runtimeenvironment . Figure đối chọi provides a relational view of the runtimeenvironment. At its heart is a Java virtual machine, which runs ontop of a device’s host operating system. Above that is aspecific J2ME configuration, which consists of programming librariesthat provide basic functionality based on the resource requirementsof the device. On đứng đầu of the configuration are one or more J2MEprofiles, which are additional programming libraries that takeadvantage of kindred functionalities on similar devices.


*

If you haven’t worked with J2ME before, you’re probablywondering about the vị trí cao nhất two layers. It’s important todistinguish between a configuration và a profile in the J2ME world,so let’s introduce them now.


Cellular telephones, pagers, organizers, và othersmall devices are diverse in form, functionality, & feature.However, they often use similar processors và have similar amountsof memory. For these reasons, the J2ME designers createdconfigurations. Configurations define ahorizontal grouping of products based on the available memory budgetand processing nguồn of each device. Once this information is known,the configuration then outlines the following:


The Java programming language features supported

The Java virtual machine features supported

The basic Java libraries and APIs supported


Currently, there are two standard configurations in the J2ME world:the Connected Limited Device Configuration(CLDC) and the Connected Device Configuration(CDC). Let’s look at the CDC first.


The CDCis targeted towardpowerful devices that are intermittently connected to a network,including set-top boxes, internet TVs, trang chủ appliances, & carnavigation systems. The CDC contains a full-featured Java virtualmachine, similar lớn that in use today with the J2SE. The differencelies in the respective devices’ memory and displaycapabilities.

Here are the resource requirements for CDC devices, as given by theofficial J2ME specifications:<1>


The device is powered by a 32-bit processor.

The device has 2 megabytes or more of total memory available forJava. This includes both RAM và flash memory or ROM.

The device requires the full functionality of the Java 2 “BlueBook” virtual machine.

The device has connectivity to some kind of network, often with awireless, intermittent connection & with limited (often 9600 bps orless) bandwidth.

The device may have a user interface with some degree ofsophistication, but a user interface is not mandatory.


The second type of configuration ismore prevalent in the J2ME world: the CLDC. This configurationspecifies a much smaller footprint for consumer and embedded devicesthan the CDC. The CLDC was first distributed in October 1999 with theidea of creating a “lowest common denominator” Javaplatform for embedded devices, specifically in terms of networking,I/O, security, and core libraries. Today, some of the devices thatyou might find powered by the CLDC include điện thoại cell phones,two-way pagers, personal digital assistants (PDAs), & personalorganizers.

Here are the requirements for the J2ME CLDC,again from the official J2ME specifications:*


In addition, the device may have a user interface with some degree ofsophistication, but a user interface is not mandatory.

Xem thêm: ĐÁº§U Tæ° Lã  Gã¬? Quy đÁ»‹Nh Về đÁº§U Tæ° Khái Niệm Đầu Tư


The two products’ configurations, alongwith some of their respective products, are shown in Figure 1-2.


*

Note that although the two sản phẩm groups are supported by differentconfigurations, the line between the two configurations is somewhatblurred. In the future, technological advances will likely make thisboundary more và more cloudy. However, for the moment, the importantthing lớn remember is that the boundary between the CLDC & the CDCis defined in terms of the target device’s memory budget,battery usage, và the presence or absence of a user interface.


As mentioned above, the CLDC và CDCconfigurations each define their own set of supported features fromthe Java virtual machine. Consequently, each requires its own Javavirtual machine. The CLDC virtual machine is far smaller than thevirtual machine required by the CDC, since it supports fewerfeatures. The virtual machine for the CLDC is called the Kilo VirtualMachine (KVM), and the virtual machine for the CDC is called the CVM.


The KVMis a complete Java runtime environment forsmall devices. It’s a true Java virtual machine as defined bythe Java Virtual Machine Specification, except for some specificdeviations that are necessary for proper functioning on smalldevices. It is specifically designed from the ground up for small,resource-constrained devices with a few hundred kilobytes’total memory.

The KVM was originally created as a research project called“Spotless” at the SunMicrosystems Laboratories. The aim of the virtual machine was toimplement a Java virtual machine for the resource-constrainedPalm Connected Organizer.<3>


The CVM is designed for larger consumer andembedded devices., such as those found with theCDC. It supports all Java 2 Version 1.3virtual machine features và libraries for items such as security,weak references, JNI, & Remote Method Invocation (RMI). Thereference implementation, currently available from Sun Microsystems,runs on Linux and VxWorks. You can tải về the referenceimplementation through the J2ME website site at http://java.sun.com/j2me/.

Initially, CVM was an acronym for “Compact” VirtualMachine. However, engineers at Sun Microsystems realized that snappymarketers (or poor spellers) may confuse the “compact” inCVM with the K in KVM. So, at present, the C does not stand foranything at all—it is simply known as the CVM.


J2ME makes it possible lớn define Java platforms for vertical productmarkets by introducingprofiles . At the implementation level, a profile isa mix of APIs that reside on top of a configuration that offers theprogram access to lớn device-specific capabilities. Following are someexamples of profiles that are currently offered through J2ME.


The MIDP is designed to be used with theCLDC, và provides a mix of APIs for useby mobile devices, such as cellular phones và two-way pagers. TheMIDP contains classes for user interface, persistence storage, andnetworking. It also includes a standardized runtime environment thatallows new applications to be “downloaded” to over userdevices. Small applications that run under the MIDP are calledMIDlets. Since thisprofile is already released, the vast majority of this book isdedicated lớn the MIDP.


The PDA profileis based on the CLDC và provides user interface APIs (which areexpected khổng lồ be a subset of the AWT) và data storage APIs forhandheld devices. As of this writing, the PDA profile is still in theworks & no reference implementation is available yet.


The Foundation profile extends the APIs provided by theCDC, but it does not provide any user interface APIs. As the name“foundation” implies, this profile is meant to serve as afoundation for other profiles, such as the Personal profile & theRMI profile.


The Personal profile extends the Foundationprofile to provide a graphical user interface (GUI) capable ofrunning Java website applets. Since PersonalJava is being redefined asthe Personal profile, it will be backward compatible withPersonalJava 1.1 và 1.2 applications. As of this writing, noreference implementation of the Personal profile is available.


The RMI profileextends the Foundation profile to provide RMI for devices. Since itextends the Foundation profile, the RMI profile is meant to be usedwith the CDC/Foundation và not the CLDC/MIDP. The RMI profile willbe compatible with J2SE RMI API 1.2.x or higher. However, as of thiswriting, no reference implementation is available yet.

Figure 1-3 shows a global snapshot of current andfuture J2ME technologies.


*

<1> The J2ME CDCspecifications are located on the Java Community Process website site asJSR-36, which can be found athttp://www.jcp.org/jsr/detail/36.jsp.


<2> note that CLDCstands for Connected Limited DeviceConfiguration, not Connectivity-Limited DeviceConfiguration. The difference between the CLDC and the CDC is not inthe type or speed of the network connection.


<3> In fact, early incarnations of the KVM contained several UIlibraries based on the “spotless” graphical toolkit.


Get Wireless Java now with the O’Reilly learning platform.

Xem thêm: Họa Giang Hồ Bất Lương Nhân, Họa Giang Hồ Chi Bất Lương Nhân Phần 4

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.