A Taste of Java ME

58 %
42 %
Information about A Taste of Java ME

Published on January 24, 2008

Author: wiradikusuma

Source: slideshare.net

A Taste of JavaME Overview to Java’s approach to wireless mobile application development from a developer’s perspective Thomas Wiradikusuma [email_address] www.wiradikusuma.com Presentation to the 19 th Java User Group Meet Up (JaMU), March 4, 2006

Objective To introduce JavaME as a platform for developing wireless mobile applications.

To introduce JavaME as a platform for developing wireless mobile applications.

Agenda Wireless mobile environment JavaME architecture JavaME versus JavaSE First MIDlet User interface and event handling Persistence Networking Game API Extensions (Messaging, Multimedia, Bluetooth, etc) Performance

Wireless mobile environment

JavaME architecture

JavaME versus JavaSE

First MIDlet

User interface and event handling

Persistence

Networking

Game API

Extensions (Messaging, Multimedia, Bluetooth, etc)

Performance

World of Wireless Mobile Wireless is in the air. Wireless communication is one of the fastest growing technology. Cell phones subscribers worldwide exceeded two billions in 2005. More depended to the Internet, people want it accessible from mobile devices. 3+G is coming to town.

Wireless is in the air.

Wireless communication is one of the fastest growing technology.

Cell phones subscribers worldwide exceeded two billions in 2005.

More depended to the Internet, people want it accessible from mobile devices.

3+G is coming to town.

Meet JavaME JavaME defined A little history Why JavaME? Dynamic delivery of content Offline access Enhanced user experience and interactive content Cross-platform compatibility Security The power of a modern object-oriented programming language Large developer community

JavaME defined

A little history

Why JavaME?

Dynamic delivery of content

Offline access

Enhanced user experience and interactive content

Cross-platform compatibility

Security

The power of a modern object-oriented programming language

Large developer community

JavaME Architecture

JavaME Architecture, cont’d Configurations: Connected Device Configuration Connected, Limited Device Configuration Profiles: Mobile Information Device Profile PDA Profile Foundation Profile etc Optional packages Typically contains functionality independent of any particular vertical market segment or device family. The main goal is to allow the definition of APIs that can be added flexibly on top of a number of different profiles. One device can support multiple optional packages.

Configurations:

Connected Device Configuration

Connected, Limited Device Configuration

Profiles:

Mobile Information Device Profile

PDA Profile

Foundation Profile

etc

Optional packages

Typically contains functionality independent of any particular vertical market segment or device family. The main goal is to allow the definition of APIs that can be added flexibly on top of a number of different profiles. One device can support multiple optional packages.

Miniaturized Standard Java APIs No floating-point in CLDC 1.0. No user class loading, object finalization, reflection, native methods, demon threads, thread groups, Collections API, etc. Simpler Runtime and System, java.io, date functions, exception handling, etc. TIPS: Always refer to Javadoc. When compiling, set Language Features and Target VM to lowest Java SDK available (IDEs can help this).

No floating-point in CLDC 1.0.

No user class loading, object finalization, reflection, native methods, demon threads, thread groups, Collections API, etc.

Simpler Runtime and System, java.io, date functions, exception handling, etc.

TIPS:

Always refer to Javadoc.

When compiling, set Language Features and Target VM to lowest Java SDK available (IDEs can help this).

Developing MIDlet Edit Source Code > Compile > Preverify > Package > Test or Deploy. Free development tools: J2ME Wireless Toolkit EclipseME (an Eclipse plug-in) NetBeans Mobility Pack (a NetBeans module) Obfuscation: minimizing the size of MIDlet suite JARs. Originally designed to foil attempts to reverse engineer compiled bytecode, perform any combination of the following functions: Renaming things to make them compact Removing unused things Inserting illegal or questionable data to confuse decompilers Other useful tools: Antenna (specialized Ant tasks to help with MIDlet suite builds) J2ME Polish Test your application in (varying) real devices as often as possible.

Edit Source Code > Compile > Preverify > Package > Test or Deploy.

Free development tools:

J2ME Wireless Toolkit

EclipseME (an Eclipse plug-in)

NetBeans Mobility Pack (a NetBeans module)

Obfuscation: minimizing the size of MIDlet suite JARs. Originally designed to foil attempts to reverse engineer compiled bytecode, perform any combination of the following functions:

Renaming things to make them compact

Removing unused things

Inserting illegal or questionable data to confuse decompilers

Other useful tools:

Antenna (specialized Ant tasks to help with MIDlet suite builds)

J2ME Polish

Test your application in (varying) real devices as often as possible.

First MIDlet (“Hello World”)

User Interface

Event Handling A command is something the user can invoke—you can think of it as a button. Like a button, it has a title, like “OK” or “Cancel,” and your application can respond appropriately when the user invokes the command. The premise is that you want a command to be available to the user, but you don't really care how it is shown on the screen or exactly how the user invokes it—keypad button, soft button, touch screen, whatever.

A command is something the user can invoke—you can think of it as a button. Like a button, it has a title, like “OK” or “Cancel,” and your application can respond appropriately when the user invokes the command. The premise is that you want a command to be available to the user, but you don't really care how it is shown on the screen or exactly how the user invokes it—keypad button, soft button, touch screen, whatever.

Persisting Data “ Record stores”, small database containing pieces of data called records . Represented by instances of javax.microedition.rms.RecordStore.

“ Record stores”, small database containing pieces of data called records . Represented by instances of javax.microedition.rms.RecordStore.

Connecting to the World All contained in the javax.microedition.io package and based around the Connection interface. HTTP (and HTTPS in MIDP 2.0) is mandatory, others are optional.

All contained in the javax.microedition.io package and based around the Connection interface.

HTTP (and HTTPS in MIDP 2.0) is mandatory, others are optional.

Connecting to the World, cont’d TIPS: Use GET rather than POST. Don't hard-code URLs. Put network access in a separate thread. Handle exceptions gracefully. Clean up after yourself.

TIPS:

Use GET rather than POST.

Don't hard-code URLs.

Put network access in a separate thread.

Handle exceptions gracefully.

Clean up after yourself.

Game API Simplifies writing 2D games. GameCanvas’ advantages over Canvas: Controls exactly when the display is updated Controls region of the screen to update Typical game loop: Graphics g = getGraphics(); while(true) { // Check for user input. // Update game state. // Draw stuff using g. flushGraphics(); } Layer, Sprite, TiledLayer and LayerManager Special effects: flashBacklight() vibrate()

Simplifies writing 2D games.

GameCanvas’ advantages over Canvas:

Controls exactly when the display is updated

Controls region of the screen to update

Typical game loop:

Graphics g = getGraphics();

while(true) {

// Check for user input.

// Update game state.

// Draw stuff using g.

flushGraphics();

}

Layer, Sprite, TiledLayer and LayerManager

Special effects:

flashBacklight()

vibrate()

Optional Packages JSR 120: Wireless Messaging API JSR 135: Mobile Media API JSR 172: Web Services Specification JSR 177: Security and Trust Services JSR 179: Location API JSR 180: Session Initiation Protocol (SIP) JSR 184: Mobile 3D Graphics JSR 190: Event Tracking API And a whole lot more…

JSR 120: Wireless Messaging API

JSR 135: Mobile Media API

JSR 172: Web Services Specification

JSR 177: Security and Trust Services

JSR 179: Location API

JSR 180: Session Initiation Protocol (SIP)

JSR 184: Mobile 3D Graphics

JSR 190: Event Tracking API

And a whole lot more…

Performance Issues Benchmarking Runtime.freeMemory() Runtime.totalMemory() System.currentTimeMilis() Run multiple times and calculate the average TIPS: First make it run, the make it run right, then make it run fast Create objects efficiently, reuse objects whenever possible Use StringBuffer for string concatenation Use arrays, not object collection Use buffered I/O Be clean Make application responsive (“perceived performance”) Use an obfuscator Redesign / refactor Run memory profiler Manage resources efficiently Don’t be too OO :-)

Benchmarking

Runtime.freeMemory()

Runtime.totalMemory()

System.currentTimeMilis()

Run multiple times and calculate the average

TIPS:

First make it run, the make it run right, then make it run fast

Create objects efficiently, reuse objects whenever possible

Use StringBuffer for string concatenation

Use arrays, not object collection

Use buffered I/O

Be clean

Make application responsive (“perceived performance”)

Use an obfuscator

Redesign / refactor

Run memory profiler

Manage resources efficiently

Don’t be too OO :-)

Resources Websites: wireless.java.sun.com www.microjava.com www.onjava.com/onjava/wireless www.javagaming.com www.microdevnet.com Books: Knudsen, Jonathan. Wireless Java Developing with J2ME, Second Edition . Apress. 2003. Riggs, Roger, et al . Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition . Addison Wesley. 2003.

Websites:

wireless.java.sun.com

www.microjava.com

www.onjava.com/onjava/wireless

www.javagaming.com

www.microdevnet.com

Books:

Knudsen, Jonathan. Wireless Java Developing with J2ME, Second Edition . Apress. 2003.

Riggs, Roger, et al . Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition . Addison Wesley. 2003.

Add a comment

Related pages

Java – TASTE-OF-IT

TASTE-OF-IT Ein Einblick in die ... Die auf Java 8 (Java SE 8, Java SE Embedded 8 und Java ME Embedded8) ... VNC Fehler – vncproxy exit code 1 mit Fehler ...
Read more

Key-Events - java-online

Webbasierte Lernumgebung zur Turtlegrafik mit Java. Turtle ... die beim Drücken einer Taste aufgerufen wird. ... ("Use cursor keys to move me ...
Read more

My first taste of Java Swing and GUI | Caitlin Vinci

About Me; Search. Search for: My first taste of Java Swing and GUI. April 15, 2016 April 16, 2016 / caitlinvinci. ... My first taste of Java Swing and GUI;
Read more

Netbeans – TASTE-OF-IT

TASTE-OF-IT Ein Einblick in die Welt der IT. Skip to content. ... Die auf Java 8 (Java SE 8, Java SE Embedded 8 und Java ME Embedded8) basiert IDE ...
Read more

Taste of Java

Taste of Java Java development and ... I have just started new project where I plan to use Java and Groovy at the same time. ... About Me. Дмитро ...
Read more

Taste download | SourceForge.net

Taste download. Taste 2013-04-11 19 ... KEEP ME UPDATED Get project updates, sponsored content from our select partners, and more. ... Java Registered
Read more

Java Program Solution Download PDF - bookamar.me

selection obtainable in addition to your wanting PDF of Java Program Solution Download. ... 2014, Taste Of Darkness, ...
Read more

Blind Taste| Java 3| Puntata 3, Receta fileto gici me ...

5. Pasi të kenë marrë ngjyrë e shuajmë me konjak dhe e ndezim me shkrepse 6. Pasi të jetë shuar flaka shtojmë ujë, gështenjat, mjaltë ...
Read more

Google

Deutschland : Erweiterte Suche Sprachoptionen: Werben mit Google Unternehmensangebote +Google Über Google Google.com
Read more