Download
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
J2ME PowerPoint Presentation

J2ME

198 Vues Download Presentation
Télécharger la présentation

J2ME

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. J2ME Java 2 Micro Edition Don Law

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

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

  4. 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 See also http://www.firststep.com.au/jlc/javacc/plusses.html slide 4

  5. Advantages of Java - Exceptions method level 4 this method can catch FileNotFound and hide it from method at level 4 method level 3 this method can throw FileNotFound if it doesn't want to handle it method level 2 Exeption FileNotFound Name, stack trace, reason, error code, etc. method level 1 throws slide 5

  6. Advantages of Java - Packages Application nvram package networking package file subsystem package CleanUp CleanUp CleanUp slide 6

  7. Advantages of Java -Automatic dependencies repeat.c caller.c #include <stdio.h> #include "repeat.h" main() { print("Repetition\n"); repeat("Copy me ", 5); printf("\n"); } #include <stdio.h> void repeat(char *s, int count) { int i; for (i=0; i<count; i++) { printf("%s", s); } } repeat.h void repeat(char *s, int count); slide 7

  8. Advantages of Java -Automatic dependencies caller.java 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

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

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

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

  12. J2ME - Micro Edition What is different? Java Card VM KVM JVM graphic is from http://java.sun.com/java2/whatis 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. slide 12

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

  14. J2ME - Micro Edition (CLDC) classes 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 IndexOutOfBoundsException UniversalFilterOutputStream InputStream UnsupportedEncodingException InputStreamReader UTFDataFormatException InstantiationException Vector Integer VirtualMachineError InterruptedException Writer InterruptedIOException slide 14

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

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

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

  18. Resources These slides are available for download from the Salient web site. http://www.salientsoftware.net Click on Resources button slide 18