Your SlideShare is downloading. ×
  • Like
A Taste of Java ME
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

A Taste of Java ME

  • 1,747 views
Published

 

Published in Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,747
On SlideShare
0
From Embeds
0
Number of Embeds
2

Actions

Shares
Downloads
60
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 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
  • 2. Objective
    • To introduce JavaME as a platform for developing wireless mobile applications.
  • 3. 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
  • 4. 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.
  • 5. 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
  • 6. JavaME Architecture
  • 7. 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.
  • 8. 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).
  • 9. 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.
  • 10. First MIDlet (“Hello World”)
  • 11. User Interface
  • 12. 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.
  • 13. Persisting Data
    • “ Record stores”, small database containing pieces of data called records . Represented by instances of javax.microedition.rms.RecordStore.
  • 14. 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.
  • 15. 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.
  • 16. 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()
  • 17. 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…
  • 18. 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 :-)
  • 19. 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.