Java™ Platform, Micro EditionPart 1 – Introduction to Java ME, CLDC and MIDPv3.0b – 25 April 20091Andreas Jakl, 2009
DisclaimerThese slides are provided free of charge at http://www.symbianresources.com and are used during Java ME courses at the University of Applied Sciences in Hagenberg, Austria at the Mobile Computing department ( http://www.fh-ooe.at/mc )Respecting the copyright laws, you are allowed to use them:for your own, personal, non-commercial usein the academic environmentIn all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.atThe correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not liable for incorrect information or damage that may arise from using the materials.This document contains copyright materials which are proprietary to Sun or various mobile device manufacturers, including Nokia, SonyEricsson and Motorola. Sun, Sun Microsystems, the Sun Logo and the Java™ Platform, Micro Edition are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Andreas Jakl, 20092
About me: Andreas JaklAssistant Professor at the University ofApplied Sciences, Hagenberg since 2006Teaching:Introduction to Software Development (1st semester BSc)Java ME (2nd semester BSc)Qt / Symbian OS (3rd semester BSc)Bachelor Thesis Seminar (5th semester BSc)Mobile Operating Systems (1st semester MSc)Interaction Technology (2nd semester MSc)Andreas Jakl, 20083
About me: Andreas JaklExperience:Forum Nokia Champion (2007, 2008, 2009)Founded company “Mopius” in 2004Internship, Master‘s Thesis and summer jobs at Siemens / BenQ Mobile (Munich, R&D)Studied Bachelor & Master of Digital Media in Hagenberg / Austria (2001 – 06)Contact:Office A.005a (FH1, lower floor)andreas.jakl@fh-hagenberg.atAndreas Jakl, 20094
Java PlatformWhat is it all about?5Andreas Jakl, 2009
The Java Platform, Part 1 / 3Javaprogramming languageCompared to C++:No pointersAutomatic garbage collectionInterfaces instead of multiple inheritanceComes with an extensive libraryAndreas Jakl, 20096
The Java Platform, Part 2 / 3Virtual Machine (JVM)Executes compiled Java bytecode (.class)Available for many systemsControls the code (security)Often used for mobile phones: Kilobyte Virtual Machine (KVM)Memory footprint starting at only 60 kB (+)Now being replaced by Hotspot JVMs.Andreas Jakl, 20097
The Java Platform, Part 3 / 3ApplicationProgramming Interfaces (APIs)Manifoldlibrariese.g. UI, network, 3D, locationbasedservices, etc.Andreas Jakl, 20098
Java?In numbers:> 6 Billion Java-enabled devices2.6 Billion Java-enabled phones(8 out of 10 shipped in 2008)3.5 Billion Java Cards20 Million Java set-top boxes800 Million Java desktops180 Operators deploying Java content6 Million developersAndreas Jakl, 20099
Java EditionsAndreas Jakl, 200910MSA … 	Mobile Service Architecture (JSRs 248 and 249)JTWI …	 Java Technology for the Wireless Industry, JSR 185MIDP …	Mobile Information Device ProfileCDC …	Connected Device ConfigurationCLDC …	Connected Limited Device ConfigurationServers & enterprise computersServers & personal computersHigh-end PDAs, TV set-top boxes, embedded devicesMobile phones & entry-level PDAsSmart cardsOptional PackagesOptional PackagesJava 2 Platform, Enterprise Edition (J2EE)Optional PackagesJava 2 Platform, Standard Edition (J2SE)Personal ProfileOptional PackagesPersonal Basis ProfileMSAJTWIFoundation ProfileMIDPCDCCLDCJava CardJava Platform, Micro Edition (Java ME)
Java MEGoing MobileAndreas Jakl, 200911
Differences J2SE / Java ME (MIDP)Java ME is mainly a subset of J2SEBut different UI- and event handling functionalityLess utility classes (only Vector and Hashtable, no LinkedLists, …)Code runs on both platforms? general algorithms: yesBut the whole application needs portingAndreas Jakl, 200912
Name: J2ME or Java ME?Official name:Java Platform, Micro Edition (Java ME)Former name:J2MEAndreas Jakl, 200913
ConfigurationDefines Java Platform for different device classes:CLDCLimited user interfaceLow computing power (usually with a battery)Network with low bandwidthCDCNetwork connection with high bandwidth, possibly persistentLarger memory requirementsAndreas Jakl, 200914
CDCEquivalent to Java SE 1.4.2 when combined with:Foundation Profile (FP)Extends CDC to Java SE 1.4.2, without graphics and UIPersonal Basis Profile (PBP)Lightweight GUI support (AWT subset)Personal Profile (PP)Extends PBP with AWT components and Appled supportFoundation for Java-based platforms:(few) smartphones, Blu-Ray, Set-top boxes, etc.Andreas Jakl, 200915
CLDCCurrentlyavailable in twoversions:1.0In devicesuntil ~ 2005 (atthelatest)1.1CurrentstandardSupports floatingpoint(but mostly in software slow)Important e.g. for GPS coordinatehandling!Usedfor:Phones (!)Consumer andentertainmentdevicesEmbedded platforms, controllers, sensorsSun SPOTsAndreas Jakl, 200916
ProfilesExtension and more detailed specification for a configurationContains APIs for UI, event handling, data storage, networks, timers, …Minimum requirements for devices (screen size, input possibilities, ...)For mobile phones:Mobile Information Device Profile (MIDP)Andreas Jakl, 200917
Profiles – Major DifferencesMIDP 1.0Hardly any sound support, limited graphicsOnly HTTP, no Sockets Many vendor-specific extensions (bad!)MIDP 2.0Game APIBetter network and multimedia supportMIDP 2.1Tries to improve fragmentation problems (different version for every phone…)Stricter specifications for packagesMIDP 3.0 (JSR 271)Multiple MIDlets can run concurrently or in the background, auto-launchMore detailed specificationsMore possibilities for the UI, support of secondary displaysAndreas Jakl, 200918
Sample Architectureof a PhoneAndreas Jakl, 200919Profile: MIDP 2.0Configuration: CLDC 1.1Virtual Machine: HotSpotOperating System
Java ME – ExamplesMotorolaMOTORAZR V3CLDC 1.0MIDP 2.0Andreas Jakl, 200920
Java ME – ExamplesNokia N70CLDC 1.1MIDP 2.0Andreas Jakl, 200921
Java ME – ExamplesSonyEricsson P990iCLDC 1.1MIDP 2.0CDC 1.0Personal ProfileAndreas Jakl, 200922
Java ME – ExamplesNokia N86 8MPCLDC 1.1MIDP 2.1MSA (Subset)Andreas Jakl, 200923
Java ME – Examples Andreas Jakl, 200924Amazon Kindle 2CDC
JSRs (Java Specification Requests)JSR = CLDC, MIDP or libraries for additional featuresDefined through:Java Community Process (JCP)Examples:JSR 82: Bluetooth APIsJSR 179: Location APIJSR 184: Mobile 3D APIJSR 226: Scalable 2D Vector Graphics APIAndreas Jakl, 200925
JSRs – How Many?Sample: supported JSRs of Nokia N86 8MPAndreas Jakl, 200926
JSRs – Games?A racing game could require:JSR 184 (3D Graphics)3D worldJSR 135 (Mobile Media)SoundJSR 82 (Bluetooth)P2P GamingJSR 180 (SIP)P2P over the networkJSR 229 (Payment)New forms of paymentAndreas Jakl, 200927Asphalt 4: Elite Racing HD© Gameloft
JSRs – Mapping Applications?A mapping application could require:JSR 226 (Vector Graphics)Map visualizationJSR 179 (Location)Where am I?JSR 172 (Web Services)Requesting dataJSR 75 (File and PIM)Map an addressJSR 238 (Internationalization)Global softwareAndreas Jakl, 200928Google Maps Mobile© Google
„Write Once, Run Anywhere™“ ?Problems:Different screen sizesBugs in manufacturers implementations (!)Different hardware performanceWhich JSRs are supported? Bluetooth? SVG? Web services?…MIDP 2.0 isn’t strict enough:Different key codes for every manufacturer (softkeys, ...)Are socket connections available?Which sound files are playable? Supported image formats?Is double buffering supported?Andreas Jakl, 200929
JTWI – Fragmentation Solution?Java Technology for the Wireless Industry (JSR 185)First try of defining full API stack to reduce fragmentationClarification of component JSR specificationsHowever: too small, too few APIs includedBad licensing politics FailedAndreas Jakl, 200930
Mobile Service Architecture(MSA, JSR 248)Goal?“Umbrella” specification, replace JTWIDefine a unified platform for majority of handsetsSpec leds: Nokia, Vodafone. Others heavily involvedDevices started to ship in 2007With at least subset of MSAAndreas Jakl, 200931
Features in MSA for CLDCAndreas Jakl, 200932Application EnvironmentVirtual MachineJSR 185JTWIJSR 118MIDP 2.0JSR 238I18NJSR 139CLDC 1.1Conditional APIsJTWI APIs
MIDP 3.0High-level goalsAdd much-requested functionality over MIDP 2Rework security model to support CLDC and CDCEnables support of MIDP 3 on CDCClarify spec and increase implementation consistencyAndreas Jakl, 200933
MIDP 3.0 Functional EnhancementsConcurrency (Multiple MIDlets at the same time)Shared libraries (LIBlets)Auto-start MIDletsIdle screen MIDletsInter-MIDlet communicationRecord store interchange formatUser Interface improvements... Andreas Jakl, 200934
Mobile Service Architecture v2Dynamic EnvironmentDownload new APIs to the handsetPlace custom middleware on handsetNext revision of MSA 248Supports both CLDC and CDCBuilds upon and requires MIDP 3.0Adds multi-tasking and on-device service frameworkAdds competitive user interface toolkitAdds device segments: entry, standard, advancedNo final release date yetAndreas Jakl, 200935
JavaFXJavaFX(http://javafx.com – integrated in NetBeans 6.5+)New UI libraries (graphics, media, web services)Consistent experience across mobile, desktop, browser, TV, etcPlus: use any Java library in JavaFXIntegrated with Java RuntimeJavaFX ScriptSimple declarative language, easier to learne.g., for artists to change sprite animation, without needing software developerAdvantage to JavaScript / ActionScript: integration with Java – reuse any Java libraryAndreas Jakl, 200936
JavaFX MobileRuns on Java ME (plus Android)Mobile content with same tools as Java FXAvailability?JavaFX Mobile Runtime needs to be pre-installed on the phoneNo phones released yetCurrently endorsed by: SonyEricsson, LGAndreas Jakl, 200937
Blu-Ray Disc Java: BD-JBased on Java ME Personal Basis Profile & earlier Java TV specGUI environment suitable for consumer electronics (no keyboard / mouse)Strong media supportApplications?Dynamic menu systemsDownloading additional content (subtitles, movie previews, etc.)Games and other bonus materialAndreas Jakl, 200938
Java ME – ApplicationsInternalsAndreas Jakl, 200939
Runtime environment (KVM)IDECode  ApplicationAndreas Jakl, 200940Source code (.java)Runtime verificationInterpreterCompile(javac).jar-file(MIDlet Suite).class-filesPackagingPreverification.class-files
PreverificationVerification: check the integrity of the byte code at runtime Too much for mobile devices, therefore: pre-verification at compile time:Takes care of resource demanding checksSimplifies runtime verificationAdds additional attributes to the .class file (5 – 15% increase in size)Andreas Jakl, 200941
MIDlet SuiteAndreas Jakl, 200942MIDlet Suite (.jar-Archiv):- Defines access rights- Possibility to share data (Record Stores)- Shared static variablesMIDlet 1MIDlet 3MIDlet 2
MIDlet-SuiteAndreas Jakl, 200943.jar-archive(MIDlet Suite)Preverified .class-file(s)Resources (icons, graphics – optional).jadfile(Applicationdescriptor, optional)ManifestInformation about .jar
ManifestText file “MANIFEST.MF”Contains meta informationAndreas Jakl, 200944Manifest-Version: 1.0MIDlet-Name: RealReplayMIDlet-Description: RealReplayMIDlet-Vendor: MopiusMIDlet-Info-URL: http://www.mopius.com/MIDlet-Version: 0.96.20MIDlet-Icon: /res/icon.pngMIDlet-1: RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDletMicroEdition-Profile: MIDP-2.0MicroEdition-Configuration: CLDC-1.1
ApplicationDescriptor (.jad)Information about .jarcontentsAllowsto check compatibilitybeforedownloading .jarAndreas Jakl, 200945MIDlet-Name: RealReplayMIDlet-Description: RealReplayMIDlet-Vendor: MopiusMIDlet-Info-URL: http://www.mopius.com/MIDlet-Version: 0.96.20MIDlet-Icon: /res/icon.pngMIDlet-1: RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDletMicroEdition-Profile: MIDP-2.0MicroEdition-Configuration: CLDC-1.1MIDlet-Jar-Size: 114185MIDlet-Jar-URL: http://realreplay.mopius.com/files/realreplay.jarAdd.
SigningAccess to some telephone functionality (e.g. socket connections, SMS) restricted: warning is displayed every timeSolution:Sign the checksum of .jar in .jad-file with an own key (certificate)Own certificate is signed with root certificate of a trusted certificate authorityAndreas Jakl, 200946
Why OTA for Deployment?Some phones (Samsung, Sagem, BREW,...) do not support installing MIDlets through the PC or BluetoothOnly alternative:Download directly through mobile phone	 Over-the-Air (OTA) deliveryAndreas Jakl, 200947
Over-the-AirAndreas Jakl, 200948HTTPWeb ServerMobile DeviceAMS (Application Management Software)JAD-ServerJAR-ServerNotification ServerGET /midlet.jadGET /midlet.jarPOST /install-notify (900 Success)200 OK200 OK200 OK
Optimization – ObfuscationOriginal intention:Make reverse engineering more difficultCode more difficult to read after de-compilationRenames classes to “a.class, b.class, …”Removes unused methods, variables, classes Significant size reductionOver-the-Air = expensive!MIDlet size restrictions in many phonesImproves speed (less code to load / parse)Andreas Jakl, 200949
ObfuscationOriginal archive79,2 kBObfuscated42,9 kB = 45% smaller!Andreas Jakl, 200950
Developing for JavaMEHighest priority: memory usage and speed often very few classes, object orientation reduced to a minimum, frequent use of static variablesBut: today’s phones have got more memoryAndreas Jakl, 200951Example:Winter Sportsfrom DigimentOpen Source (GPL)
ToolsHow to develop:52Andreas Jakl, 2009
IDEs: Sun NetBeansNetBeans (+ Mobility Pack)Andreas Jakl, 200953
IDEs: NetBeansVery good integration for mobile projects:LocalisationConditional compilationPackagingUI-Designer, game builder, …Relatively high system requirementsAndreas Jakl, 200954
IDEs: EclipseEclipse + Plugin: EclipseME / MTJ (officialplug-in)Andreas Jakl, 200955Is integrated in
IDEs: EclipseVery good IDEHelps a lot with programming errorsME integration through Eclipse ME is averageFew Java ME specific tools / support – just pure JavaAndreas Jakl, 200956
EmulatorsSun Java Wireless Toolkit for CLDC (2.5.2 / 3.0 EA)Tools for compiling, packaging and executingEmulator:DebuggingError handlingText output through consoleAllows performance analysisSimulates internet access and GPSDownload:http://java.sun.com/javame/downloads/index.jspAndreas Jakl, 200957
Sun WTKAndreas Jakl, 200958Sample applicationofNetBeans in the WTK emulator
Manufacturer-Specific EmulatorsDifferent Java ME implementations Every device manufacturer has its own emulator:Nokia:www.forum.nokia.com/Resources_and_Information/Tools/IDEs/Sony Ericsson SDK for the Java ME Platformdeveloper.sonyericsson.com/site/global/docstools/java/p_java.jspSamsunginnovator.samsungmobile.com/Motoroladeveloper.motorola.com/docstools/sdks/Andreas Jakl, 200959
J2ME PolishTools suite to address Java ME shortcomings:Own UI classes for custom, graphical UIBuild system, creates adapted version for specific handsetsAllows porting Java ME to AndroidLicensing:Free for GPL products1 commercial app: €990Unlimited commercial apps: €14,990http://www.j2mepolish.org/Andreas Jakl, 200960
Event-HandlingCommandsAndreas Jakl, 200961
Events – The Big PictureAndreas Jakl, 2009* Requires registering the MIDlet62
ListenerImplement the Listener-Interface to get informed:CommandListener: commandAction()Notification when e.g. a menu item has been selectedItemCommandListener: commandAction()Used for events for individual itemsItemStateListener: itemStateChanged()When an UI element has been changedAndreas Jakl, 200963
Recap: Interfaces?Interface: implemented by 1+ classesDefines abstract methods and constantsBut doesn’t contain the implementation!Implementing class has to override all defined methodsImportant for generic development!Caller does not need to know exact class type and name, but can work with the interface typeMore information at: http://en.wikipedia.org/wiki/Interface_(Java)Andreas Jakl, 200964Interface definition:Interface implementation:publicinterfacePredator {booleanchasePrey(Prey p);voideatPrey(Prey p);}publicclassCatimplementsPredator { publicbooleanchasePrey(Prey p) {// programmingtochaseprey p (specificallyfor a cat)     }publicvoideatPrey (Prey p) {// programmingtoeatprey p (specificallyfor a cat)     }}
CommandsCommand = semantic information about an action ( how can an action be executed?)But no actual implementation of the action!Contains:Short labelLong label (optional)TypePriorityAndreas Jakl, 2009One of them will be displayed on the screen / in the menu, depending on the available space“Intention” of the command – e.g. for special placement on the deviceFor the order of commands, if more are mapped to the same softkey. The lower the priority, the more important it is.65
Command-TypesAndreas Jakl, 200966
ExitClass HelloWorldMIDlet:… implements CommandListenerDefine new command (member variable):private Command cmdExit;Create it in the constructor:cmdExit = new Command(“Exit”, Command.EXIT, 1);frmMain.addCommand(cmdExit);frmMain.setCommandListener(this);Andreas Jakl, 2009Implementation e.g. like in the “Hello World”-Exercise67
Command HandlingMethod defined in the base class CommandListener:public void commandAction (Command c, Displayable d){if (c == cmdExit)    {destroyApp(true);notifyDestroyed();    }}Andreas Jakl, 2009true: forces shutdown, you have to free resources!false:shtudown can be prevented by the MIDlet if necessary.... mainly important if the framework wants / has to close down the app.Inform the app. manager that ourMIDlet wants to be shut down. 68
Exit SoftkeyAndreas Jakl, 200969
2 Softkeys, 3 Commands?Commands in themenu – placementdepends on thephone:Andreas Jakl, 2009NokiaSeries 40WTK 2.5Nokia S6070
Thanks for your attentionThat’s it!Andreas Jakl, 200971

Java ME - 01 - Overview

  • 1.
    Java™ Platform, MicroEditionPart 1 – Introduction to Java ME, CLDC and MIDPv3.0b – 25 April 20091Andreas Jakl, 2009
  • 2.
    DisclaimerThese slides areprovided free of charge at http://www.symbianresources.com and are used during Java ME courses at the University of Applied Sciences in Hagenberg, Austria at the Mobile Computing department ( http://www.fh-ooe.at/mc )Respecting the copyright laws, you are allowed to use them:for your own, personal, non-commercial usein the academic environmentIn all other cases (e.g. for commercial training), please contact andreas.jakl@fh-hagenberg.atThe correctness of the contents of these materials cannot be guaranteed. Andreas Jakl is not liable for incorrect information or damage that may arise from using the materials.This document contains copyright materials which are proprietary to Sun or various mobile device manufacturers, including Nokia, SonyEricsson and Motorola. Sun, Sun Microsystems, the Sun Logo and the Java™ Platform, Micro Edition are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Andreas Jakl, 20092
  • 3.
    About me: AndreasJaklAssistant Professor at the University ofApplied Sciences, Hagenberg since 2006Teaching:Introduction to Software Development (1st semester BSc)Java ME (2nd semester BSc)Qt / Symbian OS (3rd semester BSc)Bachelor Thesis Seminar (5th semester BSc)Mobile Operating Systems (1st semester MSc)Interaction Technology (2nd semester MSc)Andreas Jakl, 20083
  • 4.
    About me: AndreasJaklExperience:Forum Nokia Champion (2007, 2008, 2009)Founded company “Mopius” in 2004Internship, Master‘s Thesis and summer jobs at Siemens / BenQ Mobile (Munich, R&D)Studied Bachelor & Master of Digital Media in Hagenberg / Austria (2001 – 06)Contact:Office A.005a (FH1, lower floor)andreas.jakl@fh-hagenberg.atAndreas Jakl, 20094
  • 5.
    Java PlatformWhat isit all about?5Andreas Jakl, 2009
  • 6.
    The Java Platform,Part 1 / 3Javaprogramming languageCompared to C++:No pointersAutomatic garbage collectionInterfaces instead of multiple inheritanceComes with an extensive libraryAndreas Jakl, 20096
  • 7.
    The Java Platform,Part 2 / 3Virtual Machine (JVM)Executes compiled Java bytecode (.class)Available for many systemsControls the code (security)Often used for mobile phones: Kilobyte Virtual Machine (KVM)Memory footprint starting at only 60 kB (+)Now being replaced by Hotspot JVMs.Andreas Jakl, 20097
  • 8.
    The Java Platform,Part 3 / 3ApplicationProgramming Interfaces (APIs)Manifoldlibrariese.g. UI, network, 3D, locationbasedservices, etc.Andreas Jakl, 20098
  • 9.
    Java?In numbers:> 6Billion Java-enabled devices2.6 Billion Java-enabled phones(8 out of 10 shipped in 2008)3.5 Billion Java Cards20 Million Java set-top boxes800 Million Java desktops180 Operators deploying Java content6 Million developersAndreas Jakl, 20099
  • 10.
    Java EditionsAndreas Jakl,200910MSA … Mobile Service Architecture (JSRs 248 and 249)JTWI … Java Technology for the Wireless Industry, JSR 185MIDP … Mobile Information Device ProfileCDC … Connected Device ConfigurationCLDC … Connected Limited Device ConfigurationServers & enterprise computersServers & personal computersHigh-end PDAs, TV set-top boxes, embedded devicesMobile phones & entry-level PDAsSmart cardsOptional PackagesOptional PackagesJava 2 Platform, Enterprise Edition (J2EE)Optional PackagesJava 2 Platform, Standard Edition (J2SE)Personal ProfileOptional PackagesPersonal Basis ProfileMSAJTWIFoundation ProfileMIDPCDCCLDCJava CardJava Platform, Micro Edition (Java ME)
  • 11.
  • 12.
    Differences J2SE /Java ME (MIDP)Java ME is mainly a subset of J2SEBut different UI- and event handling functionalityLess utility classes (only Vector and Hashtable, no LinkedLists, …)Code runs on both platforms? general algorithms: yesBut the whole application needs portingAndreas Jakl, 200912
  • 13.
    Name: J2ME orJava ME?Official name:Java Platform, Micro Edition (Java ME)Former name:J2MEAndreas Jakl, 200913
  • 14.
    ConfigurationDefines Java Platformfor different device classes:CLDCLimited user interfaceLow computing power (usually with a battery)Network with low bandwidthCDCNetwork connection with high bandwidth, possibly persistentLarger memory requirementsAndreas Jakl, 200914
  • 15.
    CDCEquivalent to JavaSE 1.4.2 when combined with:Foundation Profile (FP)Extends CDC to Java SE 1.4.2, without graphics and UIPersonal Basis Profile (PBP)Lightweight GUI support (AWT subset)Personal Profile (PP)Extends PBP with AWT components and Appled supportFoundation for Java-based platforms:(few) smartphones, Blu-Ray, Set-top boxes, etc.Andreas Jakl, 200915
  • 16.
    CLDCCurrentlyavailable in twoversions:1.0Indevicesuntil ~ 2005 (atthelatest)1.1CurrentstandardSupports floatingpoint(but mostly in software slow)Important e.g. for GPS coordinatehandling!Usedfor:Phones (!)Consumer andentertainmentdevicesEmbedded platforms, controllers, sensorsSun SPOTsAndreas Jakl, 200916
  • 17.
    ProfilesExtension and moredetailed specification for a configurationContains APIs for UI, event handling, data storage, networks, timers, …Minimum requirements for devices (screen size, input possibilities, ...)For mobile phones:Mobile Information Device Profile (MIDP)Andreas Jakl, 200917
  • 18.
    Profiles – MajorDifferencesMIDP 1.0Hardly any sound support, limited graphicsOnly HTTP, no Sockets Many vendor-specific extensions (bad!)MIDP 2.0Game APIBetter network and multimedia supportMIDP 2.1Tries to improve fragmentation problems (different version for every phone…)Stricter specifications for packagesMIDP 3.0 (JSR 271)Multiple MIDlets can run concurrently or in the background, auto-launchMore detailed specificationsMore possibilities for the UI, support of secondary displaysAndreas Jakl, 200918
  • 19.
    Sample Architectureof aPhoneAndreas Jakl, 200919Profile: MIDP 2.0Configuration: CLDC 1.1Virtual Machine: HotSpotOperating System
  • 20.
    Java ME –ExamplesMotorolaMOTORAZR V3CLDC 1.0MIDP 2.0Andreas Jakl, 200920
  • 21.
    Java ME –ExamplesNokia N70CLDC 1.1MIDP 2.0Andreas Jakl, 200921
  • 22.
    Java ME –ExamplesSonyEricsson P990iCLDC 1.1MIDP 2.0CDC 1.0Personal ProfileAndreas Jakl, 200922
  • 23.
    Java ME –ExamplesNokia N86 8MPCLDC 1.1MIDP 2.1MSA (Subset)Andreas Jakl, 200923
  • 24.
    Java ME –Examples Andreas Jakl, 200924Amazon Kindle 2CDC
  • 25.
    JSRs (Java SpecificationRequests)JSR = CLDC, MIDP or libraries for additional featuresDefined through:Java Community Process (JCP)Examples:JSR 82: Bluetooth APIsJSR 179: Location APIJSR 184: Mobile 3D APIJSR 226: Scalable 2D Vector Graphics APIAndreas Jakl, 200925
  • 26.
    JSRs – HowMany?Sample: supported JSRs of Nokia N86 8MPAndreas Jakl, 200926
  • 27.
    JSRs – Games?Aracing game could require:JSR 184 (3D Graphics)3D worldJSR 135 (Mobile Media)SoundJSR 82 (Bluetooth)P2P GamingJSR 180 (SIP)P2P over the networkJSR 229 (Payment)New forms of paymentAndreas Jakl, 200927Asphalt 4: Elite Racing HD© Gameloft
  • 28.
    JSRs – MappingApplications?A mapping application could require:JSR 226 (Vector Graphics)Map visualizationJSR 179 (Location)Where am I?JSR 172 (Web Services)Requesting dataJSR 75 (File and PIM)Map an addressJSR 238 (Internationalization)Global softwareAndreas Jakl, 200928Google Maps Mobile© Google
  • 29.
    „Write Once, RunAnywhere™“ ?Problems:Different screen sizesBugs in manufacturers implementations (!)Different hardware performanceWhich JSRs are supported? Bluetooth? SVG? Web services?…MIDP 2.0 isn’t strict enough:Different key codes for every manufacturer (softkeys, ...)Are socket connections available?Which sound files are playable? Supported image formats?Is double buffering supported?Andreas Jakl, 200929
  • 30.
    JTWI – FragmentationSolution?Java Technology for the Wireless Industry (JSR 185)First try of defining full API stack to reduce fragmentationClarification of component JSR specificationsHowever: too small, too few APIs includedBad licensing politics FailedAndreas Jakl, 200930
  • 31.
    Mobile Service Architecture(MSA,JSR 248)Goal?“Umbrella” specification, replace JTWIDefine a unified platform for majority of handsetsSpec leds: Nokia, Vodafone. Others heavily involvedDevices started to ship in 2007With at least subset of MSAAndreas Jakl, 200931
  • 32.
    Features in MSAfor CLDCAndreas Jakl, 200932Application EnvironmentVirtual MachineJSR 185JTWIJSR 118MIDP 2.0JSR 238I18NJSR 139CLDC 1.1Conditional APIsJTWI APIs
  • 33.
    MIDP 3.0High-level goalsAddmuch-requested functionality over MIDP 2Rework security model to support CLDC and CDCEnables support of MIDP 3 on CDCClarify spec and increase implementation consistencyAndreas Jakl, 200933
  • 34.
    MIDP 3.0 FunctionalEnhancementsConcurrency (Multiple MIDlets at the same time)Shared libraries (LIBlets)Auto-start MIDletsIdle screen MIDletsInter-MIDlet communicationRecord store interchange formatUser Interface improvements... Andreas Jakl, 200934
  • 35.
    Mobile Service Architecturev2Dynamic EnvironmentDownload new APIs to the handsetPlace custom middleware on handsetNext revision of MSA 248Supports both CLDC and CDCBuilds upon and requires MIDP 3.0Adds multi-tasking and on-device service frameworkAdds competitive user interface toolkitAdds device segments: entry, standard, advancedNo final release date yetAndreas Jakl, 200935
  • 36.
    JavaFXJavaFX(http://javafx.com – integratedin NetBeans 6.5+)New UI libraries (graphics, media, web services)Consistent experience across mobile, desktop, browser, TV, etcPlus: use any Java library in JavaFXIntegrated with Java RuntimeJavaFX ScriptSimple declarative language, easier to learne.g., for artists to change sprite animation, without needing software developerAdvantage to JavaScript / ActionScript: integration with Java – reuse any Java libraryAndreas Jakl, 200936
  • 37.
    JavaFX MobileRuns onJava ME (plus Android)Mobile content with same tools as Java FXAvailability?JavaFX Mobile Runtime needs to be pre-installed on the phoneNo phones released yetCurrently endorsed by: SonyEricsson, LGAndreas Jakl, 200937
  • 38.
    Blu-Ray Disc Java:BD-JBased on Java ME Personal Basis Profile & earlier Java TV specGUI environment suitable for consumer electronics (no keyboard / mouse)Strong media supportApplications?Dynamic menu systemsDownloading additional content (subtitles, movie previews, etc.)Games and other bonus materialAndreas Jakl, 200938
  • 39.
    Java ME –ApplicationsInternalsAndreas Jakl, 200939
  • 40.
    Runtime environment (KVM)IDECode ApplicationAndreas Jakl, 200940Source code (.java)Runtime verificationInterpreterCompile(javac).jar-file(MIDlet Suite).class-filesPackagingPreverification.class-files
  • 41.
    PreverificationVerification: check theintegrity of the byte code at runtime Too much for mobile devices, therefore: pre-verification at compile time:Takes care of resource demanding checksSimplifies runtime verificationAdds additional attributes to the .class file (5 – 15% increase in size)Andreas Jakl, 200941
  • 42.
    MIDlet SuiteAndreas Jakl,200942MIDlet Suite (.jar-Archiv):- Defines access rights- Possibility to share data (Record Stores)- Shared static variablesMIDlet 1MIDlet 3MIDlet 2
  • 43.
    MIDlet-SuiteAndreas Jakl, 200943.jar-archive(MIDletSuite)Preverified .class-file(s)Resources (icons, graphics – optional).jadfile(Applicationdescriptor, optional)ManifestInformation about .jar
  • 44.
    ManifestText file “MANIFEST.MF”Containsmeta informationAndreas Jakl, 200944Manifest-Version: 1.0MIDlet-Name: RealReplayMIDlet-Description: RealReplayMIDlet-Vendor: MopiusMIDlet-Info-URL: http://www.mopius.com/MIDlet-Version: 0.96.20MIDlet-Icon: /res/icon.pngMIDlet-1: RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDletMicroEdition-Profile: MIDP-2.0MicroEdition-Configuration: CLDC-1.1
  • 45.
    ApplicationDescriptor (.jad)Information about.jarcontentsAllowsto check compatibilitybeforedownloading .jarAndreas Jakl, 200945MIDlet-Name: RealReplayMIDlet-Description: RealReplayMIDlet-Vendor: MopiusMIDlet-Info-URL: http://www.mopius.com/MIDlet-Version: 0.96.20MIDlet-Icon: /res/icon.pngMIDlet-1: RealReplay,/res/icon.png,com.mopius.realreplay.RealReplayMIDletMicroEdition-Profile: MIDP-2.0MicroEdition-Configuration: CLDC-1.1MIDlet-Jar-Size: 114185MIDlet-Jar-URL: http://realreplay.mopius.com/files/realreplay.jarAdd.
  • 46.
    SigningAccess to sometelephone functionality (e.g. socket connections, SMS) restricted: warning is displayed every timeSolution:Sign the checksum of .jar in .jad-file with an own key (certificate)Own certificate is signed with root certificate of a trusted certificate authorityAndreas Jakl, 200946
  • 47.
    Why OTA forDeployment?Some phones (Samsung, Sagem, BREW,...) do not support installing MIDlets through the PC or BluetoothOnly alternative:Download directly through mobile phone  Over-the-Air (OTA) deliveryAndreas Jakl, 200947
  • 48.
    Over-the-AirAndreas Jakl, 200948HTTPWebServerMobile DeviceAMS (Application Management Software)JAD-ServerJAR-ServerNotification ServerGET /midlet.jadGET /midlet.jarPOST /install-notify (900 Success)200 OK200 OK200 OK
  • 49.
    Optimization – ObfuscationOriginalintention:Make reverse engineering more difficultCode more difficult to read after de-compilationRenames classes to “a.class, b.class, …”Removes unused methods, variables, classes Significant size reductionOver-the-Air = expensive!MIDlet size restrictions in many phonesImproves speed (less code to load / parse)Andreas Jakl, 200949
  • 50.
    ObfuscationOriginal archive79,2 kBObfuscated42,9kB = 45% smaller!Andreas Jakl, 200950
  • 51.
    Developing for JavaMEHighestpriority: memory usage and speed often very few classes, object orientation reduced to a minimum, frequent use of static variablesBut: today’s phones have got more memoryAndreas Jakl, 200951Example:Winter Sportsfrom DigimentOpen Source (GPL)
  • 52.
  • 53.
    IDEs: Sun NetBeansNetBeans(+ Mobility Pack)Andreas Jakl, 200953
  • 54.
    IDEs: NetBeansVery goodintegration for mobile projects:LocalisationConditional compilationPackagingUI-Designer, game builder, …Relatively high system requirementsAndreas Jakl, 200954
  • 55.
    IDEs: EclipseEclipse +Plugin: EclipseME / MTJ (officialplug-in)Andreas Jakl, 200955Is integrated in
  • 56.
    IDEs: EclipseVery goodIDEHelps a lot with programming errorsME integration through Eclipse ME is averageFew Java ME specific tools / support – just pure JavaAndreas Jakl, 200956
  • 57.
    EmulatorsSun Java WirelessToolkit for CLDC (2.5.2 / 3.0 EA)Tools for compiling, packaging and executingEmulator:DebuggingError handlingText output through consoleAllows performance analysisSimulates internet access and GPSDownload:http://java.sun.com/javame/downloads/index.jspAndreas Jakl, 200957
  • 58.
    Sun WTKAndreas Jakl,200958Sample applicationofNetBeans in the WTK emulator
  • 59.
    Manufacturer-Specific EmulatorsDifferent JavaME implementations Every device manufacturer has its own emulator:Nokia:www.forum.nokia.com/Resources_and_Information/Tools/IDEs/Sony Ericsson SDK for the Java ME Platformdeveloper.sonyericsson.com/site/global/docstools/java/p_java.jspSamsunginnovator.samsungmobile.com/Motoroladeveloper.motorola.com/docstools/sdks/Andreas Jakl, 200959
  • 60.
    J2ME PolishTools suiteto address Java ME shortcomings:Own UI classes for custom, graphical UIBuild system, creates adapted version for specific handsetsAllows porting Java ME to AndroidLicensing:Free for GPL products1 commercial app: €990Unlimited commercial apps: €14,990http://www.j2mepolish.org/Andreas Jakl, 200960
  • 61.
  • 62.
    Events – TheBig PictureAndreas Jakl, 2009* Requires registering the MIDlet62
  • 63.
    ListenerImplement the Listener-Interfaceto get informed:CommandListener: commandAction()Notification when e.g. a menu item has been selectedItemCommandListener: commandAction()Used for events for individual itemsItemStateListener: itemStateChanged()When an UI element has been changedAndreas Jakl, 200963
  • 64.
    Recap: Interfaces?Interface: implementedby 1+ classesDefines abstract methods and constantsBut doesn’t contain the implementation!Implementing class has to override all defined methodsImportant for generic development!Caller does not need to know exact class type and name, but can work with the interface typeMore information at: http://en.wikipedia.org/wiki/Interface_(Java)Andreas Jakl, 200964Interface definition:Interface implementation:publicinterfacePredator {booleanchasePrey(Prey p);voideatPrey(Prey p);}publicclassCatimplementsPredator { publicbooleanchasePrey(Prey p) {// programmingtochaseprey p (specificallyfor a cat) }publicvoideatPrey (Prey p) {// programmingtoeatprey p (specificallyfor a cat) }}
  • 65.
    CommandsCommand = semanticinformation about an action ( how can an action be executed?)But no actual implementation of the action!Contains:Short labelLong label (optional)TypePriorityAndreas Jakl, 2009One of them will be displayed on the screen / in the menu, depending on the available space“Intention” of the command – e.g. for special placement on the deviceFor the order of commands, if more are mapped to the same softkey. The lower the priority, the more important it is.65
  • 66.
  • 67.
    ExitClass HelloWorldMIDlet:… implementsCommandListenerDefine new command (member variable):private Command cmdExit;Create it in the constructor:cmdExit = new Command(“Exit”, Command.EXIT, 1);frmMain.addCommand(cmdExit);frmMain.setCommandListener(this);Andreas Jakl, 2009Implementation e.g. like in the “Hello World”-Exercise67
  • 68.
    Command HandlingMethod definedin the base class CommandListener:public void commandAction (Command c, Displayable d){if (c == cmdExit) {destroyApp(true);notifyDestroyed(); }}Andreas Jakl, 2009true: forces shutdown, you have to free resources!false:shtudown can be prevented by the MIDlet if necessary.... mainly important if the framework wants / has to close down the app.Inform the app. manager that ourMIDlet wants to be shut down. 68
  • 69.
  • 70.
    2 Softkeys, 3Commands?Commands in themenu – placementdepends on thephone:Andreas Jakl, 2009NokiaSeries 40WTK 2.5Nokia S6070
  • 71.
    Thanks for yourattentionThat’s it!Andreas Jakl, 200971