Upload
jussi-pohjolainen
View
2.437
Download
2
Tags:
Embed Size (px)
Citation preview
Introduc)on to Java ME
Jussi Pohjolainen
INTRO TO JAVA ME PLATFORM
About Java ME
• Java ME (J2ME is older name..) is the world’s most widespread mobile applica>on pla@orm
• Developed by Sun Microsystems and bought by Oracle
Why?
• So why? Market reach! • Over 80% of phones worldwide supports Java ME!
• It’s possible to create awesome apps with new really powerful APIs: GPS, Sensors, 3D Graphics, Touch etc..
• Hardware geOng more powerful and less expensive
S40 Touch and Type
• Series 40 6th Edi)on, Feature Pack 1
• Touch enabled phone with keyboard
• Java ME APIs: Bluetooth, Web Services, Loca)on, Mobile 3D, Wireless Messaging, SVG, Mobile Media API, Gesture API..
• Price in Finland: ~130 euros
Java Pla[orms
• Java Standard Edi>on (Java SE) – Designed for desktop computers – Runs on top of OS X, Linux, Windows …
• Java Enterprise Edi>on (Java EE) – Mul)user, enterprise-‐wide applica)ons – Based on J2SE + several APIs for server-‐side compu)ng
• Java Micro Edi>on (Java ME) – For )ny, small and resource-‐constrained devices
JAVA ME TECHNOLOGY
Java Edi)ons
Java Virtual Machine KVM
Java EE Java SE
Java ME
CDC CLDC
MIDP Founda)on Profile
Personal Profile
Op)onal Packages
Op)onal Packages
Our course concentrates
on this
JCP and JSR
• Java Community Process, JCP, is a formalized process which creates defini>ons of future versions and features of the Java pla[orm.
• These defini)ons are called Java Specifica)on Requests, JSR
• JSR is a formal document that describes proposed specifica)on and technology
• There are over 300 JSRs. See list of them all.
Java ME Java Me
JVM KVM
Connected Device Configura)on (CLC)
Connected Limited Device Configura)on (CLDC)
Mobile Informa)on Device Profile (MIDP) Founda)on Profile
Personal Profile
Op)onal Packages
Op)onal Packages
Kilo Virtual Machine
• KVM is similar to JVM, runs apps wrifen in Java – language
• KVM is used in cell phones, where JVM is used on computers
• Op)mized for small size • More info: KVM White Paper
Java ME Java Me
JVM KVM
Connected Device Configura>on (CLC)
Connected Limited Device Configura>on (CLDC)
Mobile Informa)on Device Profile (MIDP) Founda)on Profile
Personal Profile
Op)onal Packages
Op)onal Packages
Configura)ons: CLDC
• CLDC (JSR 139) – Small wireless devices with intermiQent network connec)ons
– Low power consump)on – Phones, Pagers, Bar code scanners..
• CDC (JSR 36) – Larger Devices with a robust network connec)on – Set top boxes, Internet appliances
CDC -‐ CLDC
Connected Device Configura>on (CDC)
Connected Limited Device Configura>on (CLDC)
Pagers Mobile Phones PDAs Car Naviga)on Systems Internet appliances Set-‐top Boxes
smaller larger
CLDC Func)onality
• Subset of Java language • Subset of core Java SE libraries • Provides basic input and output • Provides basic networking support • Security
CLDC Libraries
• CLDC has 37 common classes from Java SE – java.lang: Boolean, Byte, Integer, Long, String… – java.u>l: Calendar, Date, Enumera)on, Hashtable..
– java.io: InputStream, OutputStream…
• CLDC 1.0 does not have floa)ng point support • CLDC 1.1 supports floa)ng point
Java ME Java Me
JVM KVM
Connected Device Configura)on (CLC)
Connected Limited Device Configura)on (CLDC)
Mobile Informa>on Device Profile (MIDP) Founda)on Profile
Personal Profile
Op)onal Packages
Op)onal Packages
The Mobile Informa)on Device Profile (MIDP)
• Specifica)on for wireless devices • Provides general Java libraries for developing apps for wireless devices
• Versions: MIDP 1.0 (JSR 37) and MIDP 2.x (JSR 118)
• MIDP 3.0 (JSR 271) under development • Great amount of devices that support MIDP
MIDP Differences
• MIDP 1.0 – Limited graphics and sound – Only HTTP, no Sockets
• MIDP 2.X – Game API – Network and Mul)media support
• MIDP 3.0 – Background MIDlets, Improved UI, Localisa)on..
MIDP Sooware Components
Device Opera)ng System
CLDC
MIDP
Op)onal Java Packages
MIDP Java App
Op)onal Device Specific Packages
Device Specific Java App
Na)ve Applica)on
Example: Nokia N97
Symbian OS v9.3
CLDC 1.1
MIDP 2.1
Op)onal Java Packages
MIDP Java App
Nokia UI API
Device Specific Java App
Na)ve Symbian App
MIDP Func)onality
• Applica)on Life Cycle Management • User Interface • Network Connec)vity • Game support
Java ME Java Me
JVM KVM
Connected Device Configura)on (CLC)
Connected Limited Device Configura)on (CLDC)
Mobile Informa)on Device Profile (MIDP) Founda)on Profile
Personal Profile
Op)onal Packages
Op>onal Packages
Op)onal Packages, JSRs • File Connec)on and PIM • Bluetooth • Wireless Messaging API (WMA) • Mobile Media API (MMAPI) • Web Services • Security and Trust Services • Loca)on API • SIP API • Mobile 3D Graphics • Java Technology for the Wireless
Industry (JTWI) • Wireless Messaging 2.0 (WMA)
• Content Handler API • SVG 1.0 • Payment API • Advanced Mul)media
Supplements (AMMS) • Mobile Interna)onaliza)on API • Java Bindings for the OpenGL ES
API • Mobile Service Architecture • Mobile Sensor API • SVG 2.0
Problems
• Different screen sizes • Bugs in phones • Performance • Fragmenta)on, JSRs
Solu)on? MSA
MIDlet Development
How to Build MIDlets?
• MIDlet = MIDP Applica)on • If Java SE is familiar, MIDlet development is easy
• Part of the API works exactly like Java SE • Building process is different
Building Process
1. Compile 2. Preverify 3. Compress 4. Create JAD-‐file 5. Upload to client
1. Compile
• Compile a MIDlet: – javac –bootclasspath \midp\classes\ MyApp.java!
• Use now base classes from Java ME! • Aoer the compile, one must preverify the result
2. Preverify
• It is cheched in the preverifing process that your MIDlet does not harm the client-‐machine.
• In Java SE this checking is done by JVM. KVM does not have this kind of security checking!
• Security checking is done in two parts – Preverify before sending MIDlet to the client machine – Client machines own check
• Command line: – preverify –classpath .;\ midp\ classes –d . Midlet!
3. Compress
• Aoer the MIDlet is compiled and preverified, you must compress all the classes (and resources) into one jar-‐file.
• Jar-‐file contains also MANIFEST.MF -‐ file, which describes the contents of the jar-‐file.
• Compressing with the jar-‐tool: – jar cvmf manifest.mf MIDlet.jar MIDlet.class!
Example of Manifest file MIDlet-1: MyMIDlet, MyMIDlet.png, MyMIDlet!MIDlet-Name: MyMIDlet!MIDlet-Vendor: Jussi Pohjolainen!MIDlet-Version: 1.0!MicroEdition-Configuration: CLDC-1.1!MicroEdition-Profile: MIDP-2.1!
4. Create JAD -‐ file
• Java Applica)on Descriptor file describes the contents of MIDlet.
• Together, .jad and .jar are called MIDlet Suite • JAD-‐file is used so that the client machine can have informa)on about the sooware before installing it.
Example of JAD-‐file MIDlet-1: MyMIDlet, MyMIDlet.png, MyMIDlet!MIDlet-Jar-Size: 1056!MIDlet-Jar-URL: MyMIDlet.jar!MIDlet-Name: MyMIDlet!MIDlet-Vendor: Unknown!MIDlet-Version: 1.0!MicroEdition-Configuration: CLDC-1.1!MicroEdition-Profile: MIDP-2.1!
Distribu)on
Preverified classes
Resource files
Manifest file
jar Jar-‐file
Jad-‐file
Mobile Phone