3. 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
4. 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
5. 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
6. 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
8. Java
Edi)ons
Our
course
concentrates
on
this
Java
ME
Op)onal
Packages
Java
EE
Java
SE
Personal
Profile
Op)onal
Packages
Founda)on
Profile
MIDP
CDC
CLDC
Java
Virtual
Machine
KVM
9. 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.
10. Java
ME
Java
Me
Op)onal
Packages
Personal
Profile
Op)onal
Packages
Mobile
Informa)on
Device
Profile
Founda)on
Profile
(MIDP)
Connected
Device
Configura)on
Connected
Limited
Device
(CLC)
Configura)on
(CLDC)
JVM
KVM
11. 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
12. Java
ME
Java
Me
Op)onal
Packages
Personal
Profile
Op)onal
Packages
Mobile
Informa)on
Device
Profile
Founda)on
Profile
(MIDP)
Connected
Device
Configura>on
Connected
Limited
Device
(CLC)
Configura>on
(CLDC)
JVM
KVM
13. 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
14. CDC
-‐
CLDC
smaller
larger
Pagers
Mobile
Phones
PDAs
Car
Naviga)on
Systems
Internet
appliances
Set-‐top
Boxes
Connected
Limited
Device
Configura>on
Connected
Device
Configura>on
(CLDC)
(CDC)
15. CLDC
Func)onality
• Subset
of
Java
language
• Subset
of
core
Java
SE
libraries
• Provides
basic
input
and
output
• Provides
basic
networking
support
• Security
16. 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
17. Java
ME
Java
Me
Op)onal
Packages
Personal
Profile
Op)onal
Packages
Mobile
Informa>on
Device
Profile
Founda)on
Profile
(MIDP)
Connected
Device
Configura)on
Connected
Limited
Device
(CLC)
Configura)on
(CLDC)
JVM
KVM
18. 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
19. 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..
21. Example:
Nokia
N97
Device
Specific
MIDP
Java
App
Java
App
Op)onal
Java
Nokia
UI
API
Packages
Na)ve
Symbian
App
MIDP
2.1
CLDC
1.1
Symbian
OS
v9.3
22. MIDP
Func)onality
• Applica)on
Life
Cycle
Management
• User
Interface
• Network
Connec)vity
• Game
support
23. Java
ME
Java
Me
Op)onal
Packages
Personal
Profile
Op>onal
Packages
Mobile
Informa)on
Device
Profile
Founda)on
Profile
(MIDP)
Connected
Device
Configura)on
Connected
Limited
Device
(CLC)
Configura)on
(CLDC)
JVM
KVM
24. Op)onal
Packages,
JSRs
• File
Connec)on
and
PIM
• Content
Handler
API
• Bluetooth
• SVG
1.0
• Wireless
Messaging
API
(WMA)
• Payment
API
• Mobile
Media
API
(MMAPI)
• Advanced
Mul)media
• Web
Services
Supplements
(AMMS)
• Security
and
Trust
Services
• Mobile
Interna)onaliza)on
API
• Loca)on
API
• Java
Bindings
for
the
OpenGL
ES
• SIP
API
API
• Mobile
3D
Graphics
• Mobile
Service
Architecture
• Mobile
Sensor
API
• Java
Technology
for
the
Wireless
Industry
(JTWI)
• SVG
2.0
• Wireless
Messaging
2.0
(WMA)
28. 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
29. Building
Process
1. Compile
2. Preverify
3. Compress
4. Create
JAD-‐file
5. Upload
to
client
30. 1.
Compile
• Compile
a
MIDlet:
– javac –bootclasspath midpclasses
MyApp.java!
• Use
now
base
classes
from
Java
ME!
• Aoer
the
compile,
one
must
preverify
the
result
31. 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!
32. 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!
33. 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!
34. 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.