Introduction To J2ME(FT - Prasanjit Dey)

2,621 views

Published on

Introduction to J2ME technology.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Introduction To J2ME(FT - Prasanjit Dey)

  1. 1. Java ME<br />Fafadia Tech<br />PrasanjitDey<br />prasanjit@fafadia-tech.com<br />
  2. 2. Introduction<br />J2ME or Java ME is a java platform designed for mobile phones and embedded systems <br />Java ME is a replacement for a similar technology known as Personal Java<br />Java ME is basically divided into two configurations<br />Connected Limited Device Configuration<br />Connected Device Configuration <br />
  3. 3. Connected Limited Device Configuration<br />The CLDC or Connected Limited Device Configuration contains a strict subset of the Java-class libraries, and is the minimum amount needed for a JVM to operate.<br />A configuration provides the most basic set of libraries and virtual-machine features that must be present in each implementation of a J2ME environment.<br />When coupled with one or more profiles, the Connected Limited Device Configuration gives developers a solid Java platform for creating applications for consumers and embedded devices.<br />CLDC has got many profiles of which MIDP is the most widely used one<br />CLDC is used with devices having limited memory and processor<br />
  4. 4. Connected Device Configuration<br />CDC or Connected Device Configuration is a subset of Java SE, containing almost all the libraries that are not GUI related<br />It is richer than CLDC<br />It has got 3 profiles namely Foundation profile , Personal basis profile and Personal profile<br />CDC profile is used for devices with more memory and processor speed<br />CDC is used in high-end PDA’s, smart phones and set-top boxes<br />
  5. 5. Profiles<br />A profile complements a configuration by adding additional classes that provide features appropriate to a particular type of device or to a specific vertical market segment<br />Profiles are layered on top of the configuration<br />Both Java ME configurations have one or more associated profiles<br />MIDP or Mobile Information Device Profile is the most widely used profile under CLDC<br />
  6. 6. MIDP<br />MIDP or Mobile Information Device Profile complements the CLDC by adding networking, user interface components, and local storage<br />This profile is primarily aimed at the limited display and storage facilities of mobile phones, and it therefore provides a relatively simple user interface and basic networking based on HTTP 1.1. <br />MIDP is the best known of the J2ME profiles because it is the basis for Wireless Java<br />MIDP provides some important API’s under CLDC such as javax.microedition.midlet, javax.microedition.lcdui, javax.microedition.rms<br />
  7. 7. Midlets and emulator<br />Java ME is a platform designed for small devices with low memory and processor speed<br />An application made using MID profile is called a midlet<br />Midlets can be run on any platform which has a JVM installed<br />Midlets needs an emulator to run them<br />An emulator is an application that run a midlet on the desktop<br />Sun’s Wireless Toolkit and EclipseME provides an emulator that are used for running a midlet<br />A group of midlets is called a midlet suite<br />
  8. 8. Midlet life cycle<br />There are three possible states in a midlet’s life cycle<br />paused – The midlet instance is created and is inactive<br />active – The midlet is active<br />destroyed – The midlet is terminated and is ready for reclamation by the garbage collector<br />When the midlet is created in response to a user request, it is in paused state. At some point later, the midlet is activated and again later can go back to the paused state and finally terminates due to the user request<br />
  9. 9. A simple midlet<br />import javax.microedition.midlet.*;<br />class simple entendsMIDLet {<br /> public simple() { // constructor<br /> }<br /> public void startApp() {<br /> // some code<br /> }<br /> public void pauseApp() {<br /> }<br /> public void destroyApp(boolean destroy) {<br /> }<br />} <br />
  10. 10. A tour of CLDC/MIDP<br />Packages:<br />javax.microedition.midlet.*;<br /> javax.microedition.io.*;<br />javax.microedition.lcdui.*;<br />javax.microedition.rms.*;<br />User Interface widgets:<br /> Form, TextField, List, TextBox, DateField, Image, Gauge, Alert, Canvas, Graphics, Display<br />Event Handling classes: <br /> Command and Command Listener<br />High level UI : Form, TextBox, etc. <br />Low level UI : Canvas, Graphics<br />
  11. 11. User Interface with MIDP<br />The javax,microedition,lcdui.*; includes several classes for displaying the interface to the screen<br />
  12. 12. Sample code using UI<br />import javax.microedition.midlet.*;<br />import javax.microedition.lcdui.*; // for using user interface widgets<br />class UIdemo extends MIDlet implements CommandListener {<br /> Form form;<br /> Display display; // helps in displaying the form<br /> Command back,save; // commands<br /> public UIdemo() {<br /> form = new Form(“Sample code”);<br /> display = Display.getDisplay(this);<br /> back = new Command(“Back”,Command.BACK,1);<br /> save = new Command(“Save”,Command.OK,1);<br />form.addCommand(back);<br />form.addCommand(save);<br />display.setCurrent(form);<br />form.setCommandListener(this);<br /> }<br /> public void startApp() {}<br /> public void pauseApp() {}<br /> public void destroyApp(boolean destroy) {} <br />public void commandAction(Command c, Displayable d) { // handler for the user actions<br /> if(c==back) destroyApp(true);<br /> else form.append(“Hello”);<br />}<br />}<br />
  13. 13. Persistent storage<br />Record Management System or rms helps in storing records locally on the device<br />It stores records in binary format<br />It stores data persistently and data can be retrieved later even after the device has been switched off<br />Records are stored in the Record Stores<br />Several methods in record store are:<br />openRecordStore()<br />closeRecordStore()<br />deleteRecordStore()<br />getRecord()<br />Enumeraterecord() and so on <br />
  14. 14. Connection types<br />All the important classes and methods for connecting the to the wireless network are included in the javax.microedition.io.* package<br />The connections types are provided by the InputStream and the OutputStream interfaces<br />These interfaces adds the ability to input and output data over the network<br />There are three important level of connections available <br />Socket<br />Datagram<br />HTTP connection<br />
  15. 15. Thank you<br />

×