Download www.salientsoftware.net

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
J2ME
Java 2 Micro Edition
Don Law
Outline
1. Java background
A. Origin of Java
B. Advantages Java brings
2. J2ME
A. Differences between J2ME and Standard Edition (security, classes)
B. The KVM
3. J2ME industry acceptance
4. Write once run anywhere?
5. J2ME examples
A. On a Linux box
B. On a Motorola cel phone
C. On a TINI chip
slide 2
Java background
Born in a Menlo Park closet at Sun in 1991
Grew out of Sun Microsystems Reasearch & Development
Oak - a language for *7 development
Integrated into browsers - WebRunner then Netscape
Only been productized since 1995
Today: 750 user groups
2,500,000 developers
2200 commercial appliations
56% of universities require learning Java
Overtake of C++ is expected next year (2003)
slide 3
Advantages of Java
Tools like Forte
now known as SunONE Studio
community edition is free
The Java Tutorial
Object oriented features built in
Encapsulation, inheritance, etc.
Modern language
Exceptions
Packages
Automatic dependencies
Pointers are encapsulated under objects
Threads are part of the language
Casting adds checks instead of suppressing
Compiler does more work for you
slide 4
See also http://www.firststep.com.au/jlc/javacc/plusses.html
Advantages of Java - Exceptions
method level 4
method level 3
this method can catch
FileNotFound and hide it
from method at level 4
method level 2
this method can throw
FileNotFound if it doesn't want
to handle it
method level 1
slide 5
throws
Exeption FileNotFound
Name, stack trace, reason, error code, etc.
Advantages of Java - Packages
Application
file subsystem
package
CleanUp
slide 6
networking
package
nvram
package
CleanUp
CleanUp
Advantages of Java Automatic dependencies
caller.c
repeat.c
#include <stdio.h>
#include "repeat.h"
#include <stdio.h>
main()
{
print("Repetition\n");
repeat("Copy me ", 5);
printf("\n");
}
repeat.h
void repeat(char *s, int count);
slide 7
void repeat(char *s, int count) {
int i;
for (i=0; i<count; i++) {
printf("%s", s);
}
}
caller.java
Advantages of Java Automatic dependencies
class caller {
public static void main(String[] args) {
System.out.println("Repetition");
repeat R = new repeat();
R.repeat("Copy me ", 5);
System.out.println("");
}
}
repeat.java
class repeat {
public void repeat(String s, int count) {
int i;
for (i=0; i<count; i++) {
System.out.print(s);
}
}
}
javac *.java
slide 8
Advantages of Java -Casting adds checks
cast.c
#include <stdio.h>
#include "increm.h"
main() {
int ok = 5;
float notok = 5.1;
int newi;
float newf;
printf("Let's cast\n");
newi = increm(&ok);
printf("New int value is %i\n", newi);
newf = increm(&notok);
printf("New float value is %f\n", newf);
}
increm.c
int increm(void *o) {
int i;
int *ptr;
ptr = (int *) o;
i = *ptr;
return i + 1;
slide 9
}
Advantages of Java -Casting adds checks
cast.java
class cast {
public static void main(String[] args) {
Integer ok = new Integer(5);
Float notok = new Float(5.1);
int newi;
float newf;
System.out.println("Let's cast");
increm I = new increm();
newi = I.increm(ok);
System.out.println(
"New int value is " + newi);
newf = I.increm(notok);
System.out.println(
"New float value is " + newf);
}
increm.java
}
class increm {
public int increm(Object o) {
Integer i;
i = (Integer) o;
return i.intValue() + 1;
}
}
slide 10
Advantages of Java -Casting adds checks
cast.c output
Let's cast
New int value is 6
New float value is 1084437248.000000
cast.java output
Let's cast
New int value is 6
Exception in thread "main" java.lang.ClassCastException: java.lang.Float
at increm.increm(increm.java:5)
at cast.main(cast.java:13)
slide 11
J2ME - Micro Edition
What is different?
JVM
KVM
Java Card VM
graphic is from http://java.sun.com/java2/whatis
slide 12
scaled down - about 1460 classes in J2SE to about 83 in CLDC
security removed (class validation, HTTPS, etc.)
profiles assume you are not on a regular computer
no floating point, persistence, or user interface components
no JNI, reflection, user class loaders, thread groups, weak
references, or finalization.
J2ME - CLDC - KVM
Rewrite of the Java Virtual Machine
Comfortable on 16 bit CPUs
KVM is about 50 Kbytes
VM plus libraries is about 128 KBytes
From J2SE:
java.lang.*
java.util.*
java.io.*
New addition:
javax.microedition.*
slide 13
J2ME - Micro Edition (CLDC) classes
slide 14
ArrayIndexOutOfBoundsException
IOException
ArrayStoreException
ISO8859_1_Reader
Boolean
ISO8859_1_Writer
Byte
Long
ByteArrayInputStream
Math
ByteArrayOutputStream
NegativeArraySizeException
Calendar
NetworkConnectionBase
CalendarImpl
NoSuchElementException
Character
NullPointerException
Class
NumberFormatException
ClassCastException
Object
ClassNotFoundException
OutOfMemoryError
ConnectionBase
OutputStream
ConnectionNotFoundException
OutputStreamWriter
Connector
PrintStream
DatagramObject
Protocol
DatagramObject
Random
DataInputStream
Reader
DataOutputStream
Runtime
Date
RuntimeException
DateParser
SecurityException
Default_Reader
Short
Default_Writer
Stack
DefaultCaseConverter
StreamReader
EmptyStackException
StreamWriter
EOFException
String
Error
StringBuffer
Exception
StringIndexOutOfBoundsException
GeneralBase
System
Hashtable
Thread
Helper
Throwable
IllegalAccessException
TimeZone
IllegalArgumentException
TimeZoneImpl
IllegalMonitorStateException
TimeZoneImplementation
IllegalThreadStateException
UniversalFilterInputStream
J2ME acceptance
First devices out in Q4 of 2000
Gartner Group: J2ME will be leveraged by
70% of smart phones and PDAs by 2004
Big presense in wireless and mobile: Canal, Fujitsu, Hitachi, Mitsubishi,
Motorola, NEC, Nokia, OnStar, Palm, Philips, Sharp, Siemens, Sony
slide 15
J2ME
Can I still write once run anywhere?
bytecodes are bytecodes
embedded tends to be more platform-specific
especially persisitence, comminication, etc.
loading and installation is not standard
writing within configurations (CLDC/CLC) and profiles (MIDP)
preserves portability
distribute a JAR without source that is usable on J2ME platforms
slide 16
J2ME Examples
On a Linux box
or anyplace GCC works
On a Motorola cel phone
CLDC compliant
serial port
network attached
On a TINI chip
Tiny Internet Network Interface by Dallas Semiconductor
on 72 pin SIMM, 1MG persistent RAM
JVM, TCP/IP stack, unix-like shell
2x RS-232, 10baseT, 1-Wire, 2x CAN
slide 17
Resources
These slides are available for download from the Salient web site.
http://www.salientsoftware.net
Click on Resources button
slide 18
Related documents