Transcript j2me
An Overview of J2ME By Jeff Heaton http://www.jeffheaton.com Using J2ME with Wireless Devices Have a J2ME Cell Phone? http://www.jeffheaton.com/j2me/ What is J2ME? Java2 Micro Edition J2ME provides a platform for smaller devices, such as (from smaller to Largest): • • • • • • Pagers Mobile Phones PDA’s Car Navigation Systems Internet Appliances Set-Top Boxes The J2ME Universe MIDP Mobile Information Device Profile Personal Profile PDAP Personal Digitial Assistant Profile CLDC Connected, Limited Device Configuration Personal Basis Profile Foundation Profile CDC Connected Device Configuration J2ME Java 2, Micro Edition MIDP Mobile Information Device Profile • 128KB of non-volatile memory for the MIDP implementation • 32KB of volatile memory for the runtime heap • 8KB of non-volatile memory for persistent data • Input capacity (screen, keyboard, touch) • Screen size of at least 96x54 pixels • Two-way network connection, possibly intermittent MIDP vs J2SE • • • • • • • • No floating point (CLDC 1.0) No Object Finalization No Reflection No Native Methods Threading, but no use of interrupt() No file-based I/O Many classes with fewer methods Collections (Vector, Hashtable & Stack) MIDP API (familiar packages) • • • • java.io java.lang java.lang.ref java.util MIDP API (no so familiar packages) • • • • • • • • javax.microedition.io javax.microedition.lcdui javax.microedition.lcdui.game javax.microedition.media javax.microedition.media.control javax.microedition.midlet javax.microedition.pki javax.microedition.rms What makes up a MIDP Application • MIDP Applications are composed of two principle parts • JAR File – Contains all of the classes and resources used by the application • JAD File – Application descriptor, describes how to run the MIDP application JAD Files • • • • • Very simple NON-XML config file Application Name MIDI version Copyright and version information Location of the JAR file Example JAD File MIDlet-1: Jargoneer, Jargoneer.png, Jargoneer MIDlet-Jar-Size: 2369 MIDlet-Jar-URL:http://www.jeffheaton.com/Jargoneer.jar MIDlet-Name: Jargoneer MIDlet-Vendor: Unknown MIDlet-Version: 1.0 MicroEdition-Configuration: CLDC-1.0 MicroEdition-Profile: MIDP-1.0 Getting Started What do I need? • J2SE (http://sun.java.com) • Sun’s J2ME Wireless Toolkit (http://java.sun.com/products/j2mewtoolkit/) • Internet Connection • Publicly accessible website or public static IP address Example: Using KToolbar and a Emulator • Live demo. Deploying MIDP • MIDP Applications are usually deployed Over the Air (OTA) • Using a HTTP web site • Can be distributed through vendor’s (i.e. Sprint) website (allows DRM) • Also can be distributed directly from any website (no DRM) Sprint Security Deploying MIDP via Web Server • Place your JAR and JAD files in a public HTTP folder. • For JAR files configure mime type: application/java-archive • For JAD files configure mime type: text/vnd.sun.j2me.app-descriptor • Point the cell phone at your JAD file: i.e. http://www.jeffheaton.com/test.jad Deploying from your computer • • • • Install web server such as Apache Determine your IP address Setup mime-types Open port 80 on your firewall, if your ISP allows you to use port 80 • Use another port (i.e. 8080 ) if your ISP does not allow port 80 • Access your website with your cell phone Things to Watch out For • • • • ISP and Cell Phone Caching Cryptic error codes Mime-Types Firewalls Useful Web Resources • Midlet Error Codes http://www.talkaboutprogramming.com/group/com p.lang.java.programmer/messages/620592.html • Deploy your J2ME Application http://www.devx.com/Java/Article/10688/0/page/2 • Sun Microsystems J2ME http://java.sun.com/j2me/ Conclusion • Questions??