introduction to java me

36
Introduc)on to Java ME Jussi Pohjolainen

Upload: jussi-pohjolainen

Post on 21-May-2015

2.435 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Introduction to Java ME

Introduc)on  to  Java  ME  

Jussi  Pohjolainen  

Page 2: Introduction to Java ME

INTRO  TO  JAVA  ME  PLATFORM  

Page 3: Introduction to Java ME

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  

   

Page 4: Introduction to Java ME

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  

Page 5: Introduction to Java ME

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  

Page 6: Introduction to Java ME

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  

Page 7: Introduction to Java ME

JAVA  ME  TECHNOLOGY  

Page 8: Introduction to Java ME

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  

Page 9: Introduction to Java ME

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.  

Page 10: Introduction to Java ME

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  

Page 11: Introduction to Java ME

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  

Page 12: Introduction to Java ME

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  

Page 13: Introduction to Java ME

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  

Page 14: Introduction to Java ME

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  

Page 15: Introduction to Java ME

CLDC  Func)onality  

•  Subset  of  Java  language    •  Subset  of  core  Java  SE  libraries  •  Provides  basic  input  and  output  •  Provides  basic  networking  support  •  Security  

Page 16: Introduction to Java ME

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  

Page 17: Introduction to Java ME

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  

Page 18: Introduction to Java ME

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  

Page 19: Introduction to Java ME

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..  

Page 20: Introduction to Java ME

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  

Page 21: Introduction to Java ME

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  

Page 22: Introduction to Java ME

MIDP  Func)onality  

•  Applica)on  Life  Cycle  Management  •  User  Interface  •  Network  Connec)vity  •  Game  support  

Page 23: Introduction to Java ME

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  

Page 24: Introduction to Java ME

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  

Page 25: Introduction to Java ME

Problems  

•  Different  screen  sizes  •  Bugs  in  phones  •  Performance  •  Fragmenta)on,  JSRs    

Page 26: Introduction to Java ME

Solu)on?  MSA  

Page 27: Introduction to Java ME

MIDlet  Development  

Page 28: Introduction to Java ME

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  

Page 29: Introduction to Java ME

Building  Process  

1.  Compile  2.  Preverify  3.  Compress  4.  Create  JAD-­‐file  5.  Upload  to  client  

Page 30: Introduction to Java ME

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  

Page 31: Introduction to Java ME

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!

Page 32: Introduction to Java ME

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!

Page 33: Introduction to Java ME

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!

Page 34: Introduction to Java ME

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.  

Page 35: Introduction to Java ME

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!

Page 36: Introduction to Java ME

Distribu)on  

Preverified  classes  

Resource  files  

Manifest  file  

jar   Jar-­‐file  

Jad-­‐file  

Mobile  Phone