Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java 2 Micro Edition Mano Chen Senior Technical Consultant

Similar presentations


Presentation on theme: "Java 2 Micro Edition Mano Chen Senior Technical Consultant"— Presentation transcript:

1 Java 2 Micro Edition Mano Chen Senior Technical Consultant
Sun Microsystems

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 J2ME Configurations and Profiles
Java HotSpot ™ Java Virtual Machine (JVM) Card VM Java Programming Language Java 2 Enterprise Edition (J2EE) Core APIs Standard (J2SE) Java 2 Micro Edition Core APIs Personal Profile RMI Other CDC Profiles ... Foundation Mobile Information Device Profile Optional Packages 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 KVM Java Card APIs

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 CLDC and MIDP Architecture
MIDP Profile Applications OEM MID Profile CLDC (KVM) Operating System APIs

16 MIDP Application Lifecycle
Pause Active Destroyed startApp destroyApp pauseApp 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 Typical J2ME Technology Stack
Mobile Information Device Profile KVM CLDC = KVM + J2ME Core APIs in this example DSP chip (e.g., ARM) J2ME core APIs Your MIDlet Yellow Pages, train schedules and ticketing, games… UI, HTTP networking... Threads, no Floats… 32-bit RISC, 256K ROM, 256K Flash, 64K RAM

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 Application Loading Process
Web Page JAM Downloads App User Selects Advertise App on Network Transfer Java Application Manager (Name, Version, Size, …) Jar File Descriptor File

20 J2ME Application Screenshots

21 Agenda Overview of J2ME Developing J2ME Application

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

23 Key J2EE Components Enterprise Java Bean Servlet Java Server Pages
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 J2ME To J2EE Communication
HTTP HTML Servlet J2ME Servlet EJB Container Web J2EE Application Server forward lookup Book

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 J2EE 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 = “ 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( “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 Security – Authentication
Build HTTP basic authentication into MIDP application Servlet Container WWW-Authenticate: Basic realm=“fred” Authorization: Basic QWxhZGpbjpvcG… GET /get_list.html HTTP/1.1 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 = “ 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
Java2 Micro Edition Wireless Toolkit t/

40 Thank You


Download ppt "Java 2 Micro Edition Mano Chen Senior Technical Consultant"

Similar presentations


Ads by Google