Your SlideShare is downloading. ×
0
Introduc)on	
  to	
  Asha	
  Pla1orm	
  
and	
  Java	
  ME	
  
Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  App...
About	
  Java	
  ME
	
  
•  Java	
  ME	
  (J2ME	
  is	
  older	
  name..)	
  is	
  the	
  world’s	
  
most	
  widespread	
...
Why?
	
  
•  So	
  why?	
  Poten1al	
  market	
  reach!	
  
•  It’s	
  possible	
  to	
  create	
  awesome	
  apps	
  with...
Some	
  history
	
  
•  Java	
  ME	
  (J2ME)	
  was	
  targeted	
  to	
  be	
  cross-­‐pla1orm	
  solu)on	
  for	
  
mobil...
Asha	
  Pla1orm
	
  
•  Asha	
  series	
  is	
  a	
  range	
  for	
  low-­‐end	
  or	
  feature	
  
phones	
  produced	
  ...
Asha	
  Pla1orm
	
  
•  UI	
  similari)es	
  from	
  Symbian	
  and	
  Meego	
  (N9)	
  
–  Swipe,	
  fast	
  lane..	
  

...
Lot	
  of	
  possibili)es
	
  
• 
• 
• 
• 
• 
• 
• 
• 
• 

Here	
  API	
  
Gestures	
  API	
  
Image	
  Scaling	
  API	
  ...
JAVA	
  ME	
  TECHNOLOGY	
  
Java	
  Pla1orms	
  
•  Java	
  Standard	
  Edi1on	
  (Java	
  SE)	
  
–  Designed	
  for	
  desktop	
  computers	
  
–  R...
Java	
  Edi)ons	
  
Our	
  course	
  
concentrates	
  
on	
  this	
  
Op)onal	
  Packages	
  

Java	
  EE	
  
Java	
  SE	
...
JCP	
  and	
  JSR	
  
•  Java	
  Community	
  Process,	
  JCP,	
  is	
  a	
  formalized	
  
process	
  which	
  creates	
 ...
Java	
  ME	
  
Java	
  Me	
  
Op)onal	
  Packages	
  
Personal	
  Profile	
  

Op)onal	
  Packages	
  

Founda)on	
  Profile...
Kilo	
  Virtual	
  Machine	
  
•  KVM	
  is	
  similar	
  to	
  JVM,	
  runs	
  apps	
  wri]en	
  in	
  
Java	
  –	
  lang...
Java	
  ME	
  
Java	
  Me	
  
Op)onal	
  Packages	
  
Personal	
  Profile	
  

Op)onal	
  Packages	
  

Founda)on	
  Profile...
Configura)ons:	
  CLDC	
  
•  CLDC	
  (JSR	
  139)	
  
–  Small	
  wireless	
  devices	
  with	
  intermiRent	
  network	
 ...
CDC	
  -­‐	
  CLDC	
  
smaller	
  

larger	
  

Pagers	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Mobile	
  Phones	
  	
  	
  ...
CLDC	
  Func)onality	
  
• 
• 
• 
• 
• 

Subset	
  of	
  Java	
  language	
  	
  
Subset	
  of	
  core	
  Java	
  SE	
  li...
CLDC	
  Libraries	
  
•  CLDC	
  has	
  37	
  common	
  classes	
  from	
  Java	
  SE	
  
–  java.lang:	
  Boolean,	
  Byt...
Java	
  ME	
  
Java	
  Me	
  
Op)onal	
  Packages	
  
Personal	
  Profile	
  

Op)onal	
  Packages	
  

Founda)on	
  Profile...
The	
  Mobile	
  Informa)on	
  Device	
  Profile	
  
(MIDP)	
  
•  Specifica)on	
  for	
  wireless	
  devices	
  
•  Provide...
MIDP	
  Differences
	
  
•  MIDP	
  1.0	
  
–  Limited	
  graphics	
  and	
  sound	
  
–  Only	
  HTTP,	
  no	
  Sockets	
 ...
MIDP	
  Soqware	
  Components	
  
MIDP	
  Java	
  App	
  	
  

Device	
  Specific	
  
Java	
  App	
  	
  

Op)onal	
  Java	...
Java	
  ME	
  
Java	
  Me	
  
Op)onal	
  Packages	
  
Personal	
  Profile	
  

Op1onal	
  Packages	
  

Founda)on	
  Profile...
Op)onal	
  Packages,	
  JSRs	
  
File	
  Connec)on	
  and	
  PIM	
  
Bluetooth	
  
Wireless	
  Messaging	
  API	
  (WMA)	
...
Problems
	
  
• 
• 
• 
• 

Different	
  screen	
  sizes	
  
Bugs	
  in	
  phones	
  
Performance	
  
Fragmenta)on,	
  JSRs	...
MIDlet	
  Development	
  
How	
  to	
  Build	
  MIDlets?	
  
•  MIDlet	
  =	
  MIDP	
  Applica)on	
  
•  If	
  Java	
  SE	
  is	
  familiar,	
  MIDl...
Example	
  MIDlet
	
  
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeExceptio...
Lifecycle:	
  startApp
•  startApp	
  –	
  method	
  is	
  called	
  when	
  MIDlet	
  has	
  
been	
  started	
  (aqer	
 ...
Lifecycle:	
  pauseApp
•  pauseApp	
  –	
  method	
  is	
  called	
  when	
  MIDlet	
  is	
  
moved	
  to	
  paused	
  sta...
Lifecycle:	
  destroyApp
•  destroyApp	
  –	
  method	
  is	
  called	
  when	
  MIDlet	
  is	
  
moved	
  to	
  destroyed...
boolean unconditional
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException...
MIDlet’s	
  Life	
  Cycle
	
  
Constructor
destroyApp()
Paused	
  

Destroyed	
  
pauseApp()

startApp()
Ac)ve	
  
Applica)on	
  Manager
	
  
•  Applica1on	
  Manager	
  controls	
  all	
  the	
  methods	
  
in	
  the	
  previous	
  slid...
Exi)ng	
  using	
  no)fyDestroyed()
	
  
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletS...
HOW	
  TO	
  BUILD	
  MIDLETS?	
  
Building	
  Process	
  
1. 
2. 
3. 
4. 
5. 

Compile	
  
Preverify	
  
Compress	
  
Create	
  JAD-­‐file	
  
Upload	
  to	
...
1.	
  Compile	
  
•  Compile	
  a	
  MIDlet:	
  
–  javac –classpath midp21.jar;cldc11.jar
MyApp.java

•  Use	
  now	
  ba...
2.	
  Preverify	
  
•  It	
  is	
  checked	
  in	
  the	
  preverifing	
  process	
  that	
  your	
  MIDlet	
  does	
  
not...
3.	
  Compress	
  
•  Aqer	
  the	
  MIDlet	
  is	
  compiled	
  and	
  preverified,	
  
you	
  must	
  compress	
  all	
  ...
Example	
  of	
  Manifest	
  file	
  
MIDlet-1: MyMIDlet, MyMIDlet.png, MyMIDlet!
MIDlet-Name: MyMIDlet!
MIDlet-Vendor: Jus...
4.	
  Create	
  JAD	
  -­‐	
  file	
  
•  Java	
  Applica)on	
  Descriptor	
  file	
  describes	
  the	
  
contents	
  of	
 ...
Example	
  of	
  JAD-­‐file	
  
MIDlet-1: MyMidlet, MyMidlet.png, MyMidlet!
MIDlet-Jar-Size: 1056 // CHECK THIS!!
MIDlet-Ja...
Distribu)on	
  
Preverified	
  classes	
  

Resource	
  files	
  

Manifest	
  file	
  

jar	
  

Jar-­‐file	
  

Jad-­‐file	
 ...
Opening	
  in	
  Emulator
	
  
•  You	
  can	
  start	
  the	
  
emulator	
  from	
  
command	
  line	
  
– 

Nokia_Asha_S...
Deploying	
  to	
  Phone
	
  
•  Transfer	
  the	
  .jad	
  
and	
  .jar	
  to	
  phone	
  using	
  
–  bluetooth	
  or	
 ...
In	
  Conclusion
	
  
•  Mobile	
  app	
  must	
  
–  extend	
  MIDlet	
  class	
  which	
  control's	
  the	
  lifecycle	...
Upcoming SlideShare
Loading in...5
×

Intro to Java ME and Asha Platform

664

Published on

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
664
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Intro to Java ME and Asha Platform"

  1. 1. Introduc)on  to  Asha  Pla1orm   and  Java  ME   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  2. 2. About  Java  ME   •  Java  ME  (J2ME  is  older  name..)  is  the  world’s   most  widespread  mobile  applica1on   pla3orm   •  Developed  by  Sun  Microsystems  and  bought   by  Oracle      
  3. 3. Why?   •  So  why?  Poten1al  market  reach!   •  It’s  possible  to  create  awesome  apps  with  new   really  powerful  APIs:  GPS,  Sensors,  3D   Graphics,  Touch  etc..   •  Hardware  geQng  more  powerful  and  less   expensive  
  4. 4. Some  history   •  Java  ME  (J2ME)  was  targeted  to  be  cross-­‐pla1orm  solu)on  for   mobile   •  Mobile  opera)ng  system  must  support  Java  for  enabling  Java   apps   •  Available  opera)ng  systems   –  Symbian  and  it's  varia)ons:  S60,  S90   –  S40   •  Symbian  is  now  dead  and  S40  has  evolved  to  Asha   •  Today:  Java  ME  is  available  for  Asha  (forget  about  the  cross-­‐ pla1orm)  
  5. 5. Asha  Pla1orm   •  Asha  series  is  a  range  for  low-­‐end  or  feature   phones  produced  by  Nokia  (and  soon  MS)   •  First  genera1on  Asha  phones  (S40  OS)   –  200  and  300  series   •  Second  genera1on  Asha  phones  (Asha   Pla1orm)   –  500  series  
  6. 6. Asha  Pla1orm   •  UI  similari)es  from  Symbian  and  Meego  (N9)   –  Swipe,  fast  lane..   •  Phones   –  Asha  500,  501,  502  and  503   •  Apps  are  wri]en  in  Java  ME  or  Web  apps   –  Powered  by  gecko  rendering  engine  (Nokia   Browser)  
  7. 7. Lot  of  possibili)es   •  •  •  •  •  •  •  •  •  Here  API   Gestures  API   Image  Scaling  API   Contact  API   Web  Services  API   Loca)on  API   Mobile  Sensor  API   Bluetooth  API   3D  Graphics  API   •  •  •  •  •  •  Internaliza)on  API   File  and  PIM  API   Mobile  Media  API   Messaging  API   Share  API   VoIP  API  
  8. 8. JAVA  ME  TECHNOLOGY  
  9. 9. Java  Pla1orms   •  Java  Standard  Edi1on  (Java  SE)   –  Designed  for  desktop  computers   –  Runs  on  top  of  OS  X,  Linux,  Windows  …   •  Java  Enterprise  Edi1on  (Java  EE)   –  Mul)user,  enterprise-­‐wide  applica)ons   –  Based  on  J2SE  +  several  APIs  for  server-­‐side   compu)ng   •  Java  Micro  Edi1on  (Java  ME)   –  For  )ny,  small  and  resource-­‐constrained  devices  
  10. 10. Java  Edi)ons   Our  course   concentrates   on  this   Op)onal  Packages   Java  EE   Java  SE   Java  ME   Personal  Profile   Op)onal  Packages   Founda)on  Profile   MIDP   CDC   CLDC   Java  Virtual  Machine   KVM  
  11. 11. JCP  and  JSR   •  Java  Community  Process,  JCP,  is  a  formalized   process  which  creates  defini1ons  of  future   versions  and  features  of  the  Java  pla1orm.   •  These  defini)ons  are  called  Java  Specifica)on   Requests,  JSR   •  JSR  is  a  formal  document  that  describes   proposed  specifica)on  and  technology   •  There  are  lot  of  JSRs.   –  h]ps://jcp.org/ja/jsr/all  
  12. 12. Java  ME   Java  Me   Op)onal  Packages   Personal  Profile   Op)onal  Packages   Founda)on  Profile   Mobile  Informa)on  Device  Profile   (MIDP)   Connected  Device  Configura)on     (CLC)   Connected  Limited  Device   Configura)on  (CLDC)   JVM   KVM  
  13. 13. Kilo  Virtual  Machine   •  KVM  is  similar  to  JVM,  runs  apps  wri]en  in   Java  –  language   •  KVM  is  used  in  cell  phones,  where  JVM  is  used   on  computers   •  Op)mized  for  small  size   •  More  info  about  KVM   –  h]p://www.oracle.com/technetwork/java/ javame-­‐old/kvmwp-­‐150240.pdf  
  14. 14. Java  ME   Java  Me   Op)onal  Packages   Personal  Profile   Op)onal  Packages   Founda)on  Profile   Mobile  Informa)on  Device  Profile   (MIDP)   Connected  Device  Configura1on     (CLC)   Connected  Limited  Device   Configura1on  (CLDC)   JVM   KVM  
  15. 15. Configura)ons:  CLDC   •  CLDC  (JSR  139)   –  Small  wireless  devices  with  intermiRent  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  
  16. 16. CDC  -­‐  CLDC   smaller   larger   Pagers                    Mobile  Phones                      PDAs                        Car  Naviga)on  Systems                      Internet  appliances                        Set-­‐top  Boxes   Connected  Limited  Device  Configura1on   (CLDC)   Connected  Device  Configura1on     (CDC)  
  17. 17. CLDC  Func)onality   •  •  •  •  •  Subset  of  Java  language     Subset  of  core  Java  SE  libraries   Provides  basic  input  and  output   Provides  basic  networking  support   Security  
  18. 18. CLDC  Libraries   •  CLDC  has  37  common  classes  from  Java  SE   –  java.lang:  Boolean,  Byte,  Integer,  Long,  String…   –  java.u1l:  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  
  19. 19. Java  ME   Java  Me   Op)onal  Packages   Personal  Profile   Op)onal  Packages   Founda)on  Profile   Mobile  Informa1on  Device  Profile   (MIDP)   Connected  Device  Configura)on     (CLC)   Connected  Limited  Device   Configura)on  (CLDC)   JVM   KVM  
  20. 20. 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)  also  available  but  not  not   implemented  in  any  phones    
  21. 21. 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..  
  22. 22. MIDP  Soqware  Components   MIDP  Java  App     Device  Specific   Java  App     Op)onal  Java   Packages   Op)onal  Device   Specific  Packages   Na)ve  Applica)on   MIDP   CLDC   Device  Opera)ng  System  
  23. 23. Java  ME   Java  Me   Op)onal  Packages   Personal  Profile   Op1onal  Packages   Founda)on  Profile   Mobile  Informa)on  Device  Profile   (MIDP)   Connected  Device  Configura)on     (CLC)   Connected  Limited  Device   Configura)on  (CLDC)   JVM   KVM  
  24. 24. 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  
  25. 25. Problems   •  •  •  •  Different  screen  sizes   Bugs  in  phones   Performance   Fragmenta)on,  JSRs  
  26. 26. MIDlet  Development  
  27. 27. 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  
  28. 28. Example  MIDlet   import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class MyMidlet extends MIDlet { public MyMidlet() { } protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { } protected void pauseApp() { } protected void startApp() throws MIDletStateChangeException { } }
  29. 29. Lifecycle:  startApp •  startApp  –  method  is  called  when  MIDlet  has   been  started  (aqer  constructor)   –  Applica1on  Management  SoVware  (AMS)  calls   the  method   –  Aqer  the  method,  the  MIDlet  is  in  Ac1vate  state   •  Method  is  called  only  once  in  Asha  pla1orm   •  What  to  do  here?   –  Acquire  needed  resources    
  30. 30. Lifecycle:  pauseApp •  pauseApp  –  method  is  called  when  MIDlet  is   moved  to  paused  state   –  In  S40:  when  phone  rings   –  In  Asha:  pauseApp  is  never  called!   •  What  to  do  here   –  In  S40:  release  any  resources   –  In  Asha:  don't  do  anything.  You  must  implement   the  method  (leave  it  blank)  
  31. 31. Lifecycle:  destroyApp •  destroyApp  –  method  is  called  when  MIDlet  is   moved  to  destroyed  state  (app  terminates)   –  Five  seconds  1me  to  do  cleaning   •  When  this  method  is  called?   –  Leaving  app  (back-­‐bu]on,  swipe)   –  AMS   –  Removing  memory  card   –  Out  of  memory  or  excep)on  in  app   •  What  to  do  here   –  Release  resources  
  32. 32. boolean unconditional import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class MyMidlet extends MIDlet { protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { if(unconditional) { // You must cleanup and release resources, we // are going to exit! } else { // You may cancel the exit request by throwing // a MIDletStateChangeException! } } }
  33. 33. MIDlet’s  Life  Cycle   Constructor destroyApp() Paused   Destroyed   pauseApp() startApp() Ac)ve  
  34. 34. Applica)on  Manager   •  Applica1on  Manager  controls  all  the  methods   in  the  previous  slide   •  You  can  try  to  change  the  state  by  using   methods  like:   –  void notifyDestroyed()! –  notifyPaused()! –  resumeRequest()!
  35. 35. Exi)ng  using  no)fyDestroyed()   import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class MyMidlet extends MIDlet { protected void destroyApp(boolean unconditional) throws MIDletStateChangeException { cleanUpResources(); } protected void pauseApp() { } protected void startApp() throws MIDletStateChangeException { cleanUpResources(); notifyDestroyed(); // destroyApp is NOT called! } private void cleanUpResources() { // .. } }
  36. 36. HOW  TO  BUILD  MIDLETS?  
  37. 37. Building  Process   1.  2.  3.  4.  5.  Compile   Preverify   Compress   Create  JAD-­‐file   Upload  to  client  
  38. 38. 1.  Compile   •  Compile  a  MIDlet:   –  javac –classpath midp21.jar;cldc11.jar MyApp.java •  Use  now  base  classes  from  Java  ME!   •  midp  classes?   –  C:NokiaDevicesNokia_Asha_SDK_1_1lib •  Aqer  the  compile,  one  must  preverify  the   result:  
  39. 39. 2.  Preverify   •  It  is  checked  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! •  Preverify  loca1on?   –  C:NokiaDevicesNokia_Asha_SDK_1_1bin!
  40. 40. 3.  Compress   •  Aqer  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!
  41. 41. 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!
  42. 42. 4.  Create  JAD  -­‐  file   •  Java  Applica)on  Descriptor  file  describes  the   contents  of  MIDlet.   •  JAD-­‐file  is  used  so  that  the  client  machine  can   have  informa)on  about  the  soqware  before   installing  it.  
  43. 43. Example  of  JAD-­‐file   MIDlet-1: MyMidlet, MyMidlet.png, MyMidlet! MIDlet-Jar-Size: 1056 // CHECK THIS!! 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!
  44. 44. Distribu)on   Preverified  classes   Resource  files   Manifest  file   jar   Jar-­‐file   Jad-­‐file   Mobile   Phone  
  45. 45. Opening  in  Emulator   •  You  can  start  the   emulator  from   command  line   –  Nokia_Asha_SDK_1_1_e m.exe -classpath "MyMidlet.jar" "MyMidlet.jad"
  46. 46. Deploying  to  Phone   •  Transfer  the  .jad   and  .jar  to  phone  using   –  bluetooth  or   –  mass  storage  
  47. 47. In  Conclusion   •  Mobile  app  must   –  extend  MIDlet  class  which  control's  the  lifecycle   –  package  all  files  in  JAR     •  include  MANIFEST.MF  file  contained  in  JAR  file   –  include  a  Java  Applica)on  Descriptor  (JAD)  file   –  have  all  .class  preverified  before  deployment  
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×