Embed
Email

J2ME Basics

Document Sample
J2ME Basics
Description

J2ME Basics

Introduction to J2ME

1



What is J2ME

• J2ME is ‘Java 2 Platform, Micro Edition’. It is the edition of the Java 2 platform targeted at consumer electronics and embedded devices. The J2ME technology consists of a virtual machine and a set of APIs suitable for providing tailored runtime environments for consumer and embedded electronics. The J2ME technology has two primary kinds of components--configurations and profiles.

2



1



What is J2ME?(cont’)

• J2ME is a new, very small Java application environment. It is a framework fro the deployment and use of java technology in the post-PC world.



3



Example of J2ME Environment



4



2



Where does J2ME stand?



5



J2ME Software Layer Stack



6



3



Configuration and Profile



7



Configuration

• A configuration is comprised of a virtual machine, core libraries, classes and APIs. It specifies a generalized runtime environment for consumer electronic and embedded devices, and acts as the Java platform on the device. • Two J2ME configurations:

– The Connected Limited Device Configuration (CLDC) – The Connected Device Configuration (CDC)



8



4



CLDC

• The CLDC provides a virtual machine and basic class libraries to support Java language applications on consumer electronic and embedded devices such as smart communicators, pagers, personal digital assistants (PDAs), and interactive, digital television set-top boxes. • CLDC is designed for devices with constrained CPU and memory resources. Typically, these devices run on either a 16- or 32-bit CPU and have 512Kbytes or less memory available for the Java platform and applications. Minimal is 160KB with 128KB for the storage for the actual virtual machine and libraries. 9 • CLDC runs on top of the K virtual machine



CLDC Libraries

Classes inherited from J2SE : • java.lang.* • java.util.* • java.io.* New classes introduced by CLDC • javax.microedition.*

10



5



CLDC Libraries: java.lang.*

• • • • • • • • java.lang.Object java.lang.Class java.lang.Runtime java.lang.System java.lang.Threadjava.lang.Runnable java.lang.String java.lang.StringBuffer java.lang.Math java.lang.Throwable java.lang.Byte java.lang.Long java.lang.Integerjava.lang.Boolean java.lang.Character java.lang.Short

11



CLDC Libraries: java.util.*

• • • • • • java.util.Vector java.util.Hashtable java.util.Random java.unti.Stack java.util.Enumeration java.util.Calender

12



6



CLDC Libraries: java.io.*

• • • • • • • java.io.InputStream java.io.OutputStream java.io.Reader java.io.Writer java.io.DataInput java.io.DataOutput java.io.OutputStream java.io.PrintStream java.io.inputStreamReader java.io.ByteArrayInputStream java.io.ByteArrayOutputStream

13



Class File Verification



14



7



The virtual machine used in CLDC

• KVM is Sun’s K Virtual Machine, a virtual machine designed from the ground up with the constraints of inexpensive mobile devices in mind. • Named to reflect that its size is measured in the tens of kilobytes.



15



KVM

• Extends the reach of JavaTM technology into low-end network connected devices • Is a key component of the Java 2 Platform, Micro Edition (J2METM technology) environment • Is the smallest general purpose Java virtual machine offered by Sun Microsystems, Inc.

16



8



KVM (cont’)

• Offers superior savings in Java memory usage • Runs effectively on low power 16 bit or higher processors • Offers exceptional Java performance in resource-constrained devices



17



Features of KVM

• Reduced VM Size: only 50 - 80K object code in its standard configuration • Reduced Memory utilization: requires only a few tens of kilobytes of dynamic memory to run effectively • Performance: is able to run effectively on 16 bit processors clocked as low as 25 MHz, and can scale smoothly up to much 18 more powerful 32 bit processors



9



Features of KVM(cont’)

• Portability:

– has a highly portable architecture – multi-threading and garbage collection have been implemented in a completely system-independent manner



• Maitain all the central features of Java programming laguage • Clean, portable, modular and customizable • Implemented in the C programming language • for more information: http://java.sun.com/products/cldc

– [The K Virtual Machine Datasheet.htm]

19



Sun’s KVM can be compiled and tested on

• Solaris Operating System • Windows • Test bed – Palm OS platform Other KVM implementations have been ported on more than 25 devices



20



10



Issues Addressed by CLDC

• • • • • • Java language and virtual machine features Core Java Libraries Input/Output Networking Security Internalization

21



CDC

• CDC is designed for next-generation devices with more robust resources. Typically these devices run on a 32-bit CPU and have 2Mbytes or more memory available for the Java platform and applications. • A superset of CLDC, a CLDC-compliant profile is upwardly compatible with CDC • CDC runs on top of C Virtual Machine (CVM)

22



11



CDC Overview

• CDC Standardization: CDC is a Java Community Processsm effort(JSR-36) that standardized a portable, Java technology building block for consumer electronic and embedded devices. • Memory Footprint: Two MB or more of total memory, including both RAM and flash or ROM

23



CDC Overview(cont’)

• Connectivity: Target devices contain connectivity to a network, often a wireless, intermittent connection, with limited bandwidth(9600bps or less) • CDC Class Library: the minimal set of APIs needed to support a virtual machine.

– – – – – java.lang – VM system clasess Java.util – underlying java utilities Java.net – UDP datagram and file I/O Java.io – Java file I./O Java.text – bare minimal support for I18n(ex. For error messages) 24 – Java.security – minimal fine-grain securing



12



Virtual machine used in CDC

• CVM: C Virtual Machine • Has only one profile now – the Foundation Profile • Employs a modular configuration and profile architecture



25



CVM Overview

• Memory System

– Exactness – Small average garbage collection pause time – Full separation of VM from memory system – Pluggable garbage collectors – Generational garbage collection



26



13



CVM Overview(con’t)

• Portability

– Implemented in C, with very little Assembler – Contains a rich, well-documented porting layer that is RTOS-aware, supports multiple porting options



27



CVM Overview(cont’)

• Fast Synchronization

CVM performs most synchronization operations with just a few machine instructions, and without consuming additional lock resources from the underlying operation system.



• ‘ROMable’ Classes CVM can run with preloaded, mostly read-only classes, alongside dynamically loaded classes. This provides better startup time, less fragmentation, more data sharing, and the ability to execute bytecodes out of ROM

28



14



CVM Overview(cont’)

• Native Thread Support Supports native threads and arbitrary thread preemption at machine instruction boundaries. • Small Class Footprint • Java 2 Platform, Version 1.3 VM Support Supports the full Java 2 platform, version 1.3 VM specification and libraries

29



CVM Overview(cont’)

• Stack Usage CVM features deterministic and reducedfootprint native stack usage, achieved by careful static analysis of the VM code. The static analysis has resulted in the placement of native stack checks at possible recursion points in the VM code to detect and prevent native stack overflows.

30



15



CVM Overview(cont’)

• Startup and Shutdown CVM can cleanly shutdown and restart in a single address space OS, such as an RTOS, without help from a process model, freeing up all allocated memory and stopping all threads without any resource leaks.



31



CVM Overview(cont’)

• Interfaces CVM provides extensible and well-defined interfaces. The interfaces between components, such as garbage collection, type system, locking, and interpreter are clearly defined, well-separated, and well-documented. It is much easier to add new features to CVM compared to the previous PersonalJava virtual machine.

32



16



Profile

• Why profile?

– To further enhance the value of the J2ME environment – To assure its ability to provide a focused solution to particular device categories and industries



33



What is a profile?

• A profile is an industry-defined specification that details the JavaTM technology APIs, built on top of and utilizing the underlying configuration, necessary to provide a complete runtime environment for a specific kind of device.



34



17



Features of A Profile

• A profile is an attempt by Java to overcome the hindrances of a ‘market segment’ or a different ‘device family’ or ‘application domain’ • Profiles can serve two distinct portability requirements:

– Provides a complete toolkit for implementing applications for a particular kind of device such as a pager, set-top box, cell phone etc – Supports a significant, coherent group of applications that might be hosted on several categories of devices

35



Features of A Profile(cont’)

• Value Proposition to the consumer is that an application written for a particular profile will run on any device that supports that profile(Right now only one of these profiles in existence i.e. MIDP). It is designed for the cell phones and related devices



36



18



Issues Addressed by Profiles

• • • • Life-cycle management User Interface Event Handling High-level application model



37



How to define profiles?

• Profiles are defined by open industry working groups utilizing Sun's Java Community ProcessSM Program. In this way industries can decide for themselves what elements are necessary to provide a complete solution targeted at their industry. For more information on the Sun Community Process Program see: http://java.sun.com/aboutjava/communityprocess/



38



19



Profiles Existing or Underway

• Personal Profile: next-generation Personal Java technology • Wireless Profile: Mobile Information Device (MID) • Other Profiles: example profiles from industries participating in defining J2ME



39



Difference between a Profile and a Configuration

Configuration • A Configuration defines a minimum platform for a horizontal category or grouping of devices. • Class libraries are not very domain specific



Profile • A J2ME device profile is layered on top and thus extends a configuration • Class libraries are more domain specific than in a Configuration 40



20



Difference between a Profile and a Configuration(cont’)

• A Configuration meets the demands of the horizontal category of devices • Eg. CLDC 1.0 specification available for free download now • A Profile addresseds the specific demands of the ‘vertical market segment’ or ‘device family’ • Eg. MIDP 1.0 spec and implementation is now available for free download now

41



J2ME and WAP

• WAP and MIDP: complementary technology • WAP supported by major phone manufactures • WAP – additional phone functionally like call setup, sending DTMF tones, etc • MIDP has media rich features – good for games and entertainment • No browsing technology in MIDP • An integrated WAP browser and MIDP – and ideal solution

42



21



Features not supported by J2ME

• • • • • Floating point data types Java Native Interface(JNI) Reflection features Thread groups Limited on errro handling



43



Make your own palm application

• Download the CLDC and KVM from SUN site • Write your code for the application • Compile all the files inside database directory into classes directory at c:\j2me_cldc\tools\palm • Compile the java code • Pre-verify the class file of your application • Generate the palm application from the preverified application • Load it on you palm

44



22



Future Direction (Sun Microsystems)

Future evolution of CLDC and KVM and provision of tools to accomplish the following • Optimize the class file format to reduce space requirements and loading time • Provide better support for Java level debugging and IDE integration • Improve performance of essential virtual machine components such as garbage collector, class loader and thread synchronization • J2ME is still evolving technology • Future versions of J2ME will support JINI • Now Nokia, Motorola and LG telecom support 45 J2ME



To learn more about the Java 2 Platform, Micro Edition and other Java technologies, please visit: • The Java 2 Platform, Micro Edition: http://java.sun.com/j2me/ • CLDC and the K virtual machine (KVM): http://java.sun.com/products/cldc/ • CDC and the C virtual machine (CVM): http://java.sun.com/products/cdc/ • PersonalJava: http://java.sun.com/products/personaljava/ • EmbeddedJava: http://java.sun.com/products/embeddedjava/ • The Java Community Process: http://java.sun.com/aboutJava/communityprocess/ http://www.sun.com/communitysource/j2me/ 46



23





Related docs
Other docs by Shariq Bashir
SEO_Basics
Views: 94  |  Downloads: 8
J2ME step by step
Views: 1193  |  Downloads: 156
J2ME Introduction Configurations
Views: 254  |  Downloads: 40
SEO and search engines
Views: 17  |  Downloads: 1
PHP introduction
Views: 19  |  Downloads: 4
SEO_Web_Developer_Cheat_Sheet
Views: 14  |  Downloads: 1
The Essential Code for SEO
Views: 27  |  Downloads: 2
Introduction to SEO
Views: 44  |  Downloads: 6
Java PDF Converter
Views: 363  |  Downloads: 5
XML programming in JAVA
Views: 310  |  Downloads: 61
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!