1 / 40

Java 2 Micro Edition

Java 2 Micro Edition. Mano Chen Senior Technical Consultant Sun Microsystems Mano@sun.com. Computing Is Becoming Ubiquitous. Mainframe era One computer, many users PC era One computer, one user Consumer era One user, many computers, and these computers are networked. A Game.

halona
Download Presentation

Java 2 Micro Edition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java 2 Micro Edition Mano Chen Senior Technical Consultant Sun Microsystems Mano@sun.com

  2. Computing Is Becoming Ubiquitous • Mainframe era • One computer, many users • PC era • One computer, one user • Consumer era • One user, many computers, and these computers are networked

  3. A Game • What am I? • I have the following: • CPU • some memory • screen • keyboard • networked • runs applications

  4. Meet Your New Computers

  5. Agenda • Overview of J2ME • Developing J2ME Application

  6. Agenda • Overview of J2ME • Developing J2ME Application

  7. Problems • No software market !!! • Everything is proprietary • Hardware, software and tools • Handsets are useless without a network • No compelling content

  8. J2ME is the Solution • Designed for small devices • Online and offline activities • Rich user and network interaction models • Fully programmable • Portable

  9. Where Does J2ME Fit In?

  10. Java™ 2 Platform, Micro Edition (J2ME™) encompasses VMs and core APIs specified via Configurations as well as vertical—or market-specific—APIs specified in Profiles Optional Packages Optional Packages Java 2 Enterprise Edition (J2EE) Core APIs Java 2 Standard Edition (J2SE) Core APIs Other CDC Profiles ... Personal Profile RMI Profile Foundation Profile Mobile Information Device Profile Java Card APIs Java 2 Micro Edition Core APIs Java Programming Language Java HotSpot ™ Java Virtual Machine (JVM) KVM Card VM J2ME Configurations and Profiles

  11. What Is a Configuration? • Defines the minimum capabilities and libraries for a JVM that will be available on all devices belonging to the same “horizontal” family of devices • Similar requirements in memory size and processing capabilities • Subject to compatibility test • Two configuration defined • Connected, Limited Device Configuration • Connected Device Configuration

  12. Connected Limited Device Configuration • Targeted at devices with • 160KB to 512KB total memory available for Java™ technology • Slow processor • Limited power (often battery) • Limited, perhaps intermittent connectivity to a network (often wireless) • Extremely constrained UIs, small screens • CLDC 1.0 specification available for free download now • Sun provides CLDC reference implementation built using the KVM

  13. What Is a Profile? • A collection of Java technology-based APIs that supplement a Configuration to provide capabilities for a specific “vertical” market or device type • Adds features that are specific to a certain device category such as cell phones or PDAs • One profile defined • Mobile Information Device Profile

  14. Mobile Information Device Profile • Targets mobile two-way communication devices implementing J2ME CLDC • Profile addresses • Display toolkit, User input methods • Persistent data storage using simple record-oriented database model • HTTP-based networking using CLDC Generic Connection framework • MIDP 1.0 spec and implementation available for download now

  15. MIDP Profile Applications OEM Applications MID Profile OEM APIs CLDC (KVM) Operating System CLDC and MIDP Architecture

  16. Pause pauseApp startApp Active destroyApp destroyApp Destroyed MIDP Application Lifecycle • MIDP applications are known as “MIDlets” • MIDlets move from state to state in the lifecycle, as indicated. • Start – acquire resources and start executing • Pause – release resources and become quiescent (wait) • Destroy – release all resources, destroy threads, and end all activity

  17. Your MIDlet Yellow Pages, train schedules and ticketing, games… Mobile Information Device Profile UI, HTTP networking... J2ME core APIs CLDC = KVM + J2ME Core APIs in this example Threads, no Floats… KVM 32-bit RISC, 256K ROM, 256K Flash, 64K RAM DSP chip(e.g., ARM) Typical J2ME Technology Stack

  18. MIDlet Suite • MIDlets are package as a JAR • MIDlets that are in the same suite can access each others database • A descriptor file contains information pertaining to the suite • Vendor name, version, size • Name of each MIDlet • Icons

  19. Advertise App on Web Page User Selects App JAM Downloads App Web Page (Name, Version, Size, …) Java Application Manager Descriptor File Network Transfer Jar File Application Loading Process

  20. J2ME Application Screenshots

  21. Agenda • Overview of J2ME • Developing J2ME Application

  22. Integration Tier Client Tier Web Tier Business Tier EIS Tier J2EE Architecture

  23. Key J2EE Components • Enterprise Java Bean • Business logic packaging, distribution and access • Servlet • Java classes that extends the function of a web server • Java Server Pages • Templates used to generate content dynamically • J2EE Connectors • Generic access to back end EIS

  24. Example of A J2EE Application • EJB is used to encapsulate business logic and apply them to EIS back office systems • Servlets are used to co-ordinate the interactions between users and EJBs • JSPs are used to present forms, information and results back to the user

  25. J2EE Application Server Web Container EJB Container HTTP J2ME Servlet Book EJB forward lookup HTML Servlet HTTP J2ME To J2EE Communication

  26. Handling J2ME Client • A request is made to the servlet • Process the request • Servlet determines if the type of client • Redirect to J2ME servlet for all J2ME client communications

  27. Design Issues • Networking • Application messages • Working offline • Security

  28. Networking • J2ME side • Use HTTP 1.1 – requirement for all MIDP devices • Use GET and POST communicating with web tier • Client is responsible for HTTP headers and data • J2EE side • Use servlet to handle client request

  29. MIDP Networking – Request 01 String url = “http://www.books.com/web/list?isdn=12345”; 02 03 HttpConnection con = (HttpConnection)Connection.open(url); 04 con.setRequestMethod(HttpConnection.POST); 05 06 con.setRequestProperty(“user-agent”, “CLDC-MIDP”); 07 con.setRequestProperty(“content-language”, “en”); 08 con.setRequestProperty(“content-type” 09 , “application/x-www-form-encoded”); 10 11 switch (con.getResponseCode( )) { 12 …

  30. MIDP Networking – Response 01 InputStream is = con.openInputStream(); 02 03 if (is.getType( ) != “application/mybook-encoding”) 04 // Reject data stream 05 06 byte buffer = new byte[256]; 07 int size; 08 while ((size = is.read(buffer)) != -1) { 09 // Do something with data 10 11 is.close( ); 12 // Display the data

  31. Servlet – Existing 01 public void doPost(HttpServletRequest req, 02 HttpServletResponse res) … { 03 04 // Looks up book 05 String isdn = req.getParameter(“isdn”); 06 07 if (req.getHeader(“user-agent”).equals(“CLDC-MIDP”) { 08 RequestDispatcher rd = req.getRequestDispatcher( 09 “MIDPcommunications”); 10 rd.forward(req, res); 11 return; 12 } 13 14 // Normal processing

  32. Servlet – MIDP Servlet 01 public void doPost(HttpServletRequest req, 02 HttpServletResponse res) … { 03 04 res.setContentType(“application/mybook-encoding”); 05 06 ServletOutputStream os = res.getOutputStream( ); 07 // Write data out 08 09 os.flush( );

  33. Application Messages Since 3G is NOT with us yet… • Conserve bandwidth • Send only the necessary data • Accommodate high latency • Send all required data in a single message • Use Gauge to provide progress indication • Message encodings • Use binary messages • Don’t use XML!!!

  34. Working Offline • MIDP supports record oriented database • Data can be stored locally on the CLDC device • Information stored in local databases can be manipulated • Need to implement data synchronization

  35. WWW-Authenticate: Basic realm=“fred” Servlet Container Authorization: Basic QWxhZGpbjpvcG… GET /get_list.html HTTP/1.1 Security – Authentication • Build HTTP basic authentication into MIDP application 01 if (con.getHeaderField(“www-authenticate”) != null) { 02 String authString = Base64.encode(login + “:” + password); 03 con.setRequestProperty(“authorization”, “basic “ + authString); 04 if (con.getResponseCode() != HttpConnection.HTTP_OK) { 05 // Do something … 06 else

  36. Security – Authentication • Use JSP/Servlet form login • Use j_security_check method for authentication • Required parameters are j_username and j_password 01 String url = “http://www.books.com/web/j_security_check”; 02 url += “?j_username=“ + username; 03 url += “&j_password=“ + password; 04 HttpConnection con = (HttpConnection)Connection.open(url); 05 06 con.setRequestMethod(HttpConnection.POST);

  37. Security – Secure Transport • HTTPS is not a requirement for MIDP 1.0 • However… • Vendors are implementing them • J2ME for Palm supports HTTPS • HTTPS support targeted for MIDP-NG

  38. Summary • Designed for small handheld devices • Easy to program • Works with J2EE • It’s real and its available now!!!!

  39. Getting Started on J2ME • Java2 Standard Edition • http://java.sun.com/j2se • Java2 Micro Edition Wireless Toolkit • http://java.sun.com/products/j2mewtoolkit/

  40. Thank You

More Related