Java Platform, Micro Edition (Java ME) Mokoena F.R The 7046 Team 1. Introduction Java Platform, Micro Edition (Java ME) technology is one of the popular mobile application runtime. It provides developers with the opportunity to deploy a single code base across different platforms. These include the most popular series 40 platform and the S60 platform. It is the objective of this report to provide a brief discussion on Java ME Platform. The report is divided into two parts; the first part describes what JME is, concentrating more on CLDC and its profile, since is of more importance in the mobile gaming. The second part is devoted into the JME development process. 2. What is Java ME? JME is the version of Java platform designed for use in variety of devices, such as cell phones and TV set-tops boxes [1]. Figure 1 shows how Java platform is divided into several editions. Java ME applications can be deployed in any device supporting the Mobile Information Device Profile (MIDP). Java ME is further divided into two configurations, each having its own profile. The first one is Connected Device Configuration (CDC), which is suitable for devices with large range of user interface capabilities, large memory, and high bandwidth networking capabilities. The other configuration associated with Java ME is Connected, Limited Device Configuration (CLDC). This configuration is indented for devices with limited storage capability, simple user interface and normally battery operated. These devices also have some networking capability. 1
Servers & enterprise computers Desktop & personal computers High-end consumer devices Low-end consumer devices Smartcards Optional Packages Java 2 Enterprise Edition (J2EE) Optional Packages Java 2 Standard Edition Personal Profile Foundation Profile MIDP (J2SE) CDC CLDC Java Card Java Virtual Machine KVM CardVM Java ME Figure 1: Java platform (adapted from [2]) The configuration also specifies the Virtual Machine and the set of Application programming Interfaces (APIs) supported. The next section takes a closer look at MIDP, the profile for CLDC. 2.1 MIDP MIDP is a version of the Java platform based on CLDC and KVM that is targeted at small footprint devices. The CLDC is installed on the native operating system and is a basis for MIDP. MIDP defines the characteristics of the device, taking into consideration the screen and memory limitations of the device. These characteristics include the user interface components, input and event handling, persistent storage, networking and timers [3]. Native applications run on top of the native operating system and they are host device dependent. 2
OEM Specific Applications MIDP Applications OEM Specific Classes MIDP CLDC Native Applications Native Operating System Device Figure 2: MIDP architecture (adapted from [2]) 2.2 MIDlets Java application that runs on a MIDP device is referred to as MIDlet. A MIDlet contains at least one java class. A collection of these classes, and non-class information packaged in to a JAR file form a MIDlet suite. The application manager on a device uses this jar file to install or uninstall the application. Packaging information that tells the device what is in the JAR must be supplied in the JAR's manifest file. Similar packaging information is also provided in another file called the Java application descriptor (or JAD file for short), which is held separately from the JAR. Both the manifest file and the JAD file are simple text files in which each line has the form: attribute-name: attribute-value The Jar file for the MIDlet might be too large to be downloaded over a relatively slow network. To overcome this problem, the JAD file, which is smaller than, the JAR file is fetched and its contents are displayed on the device, so that the user can decide whether to fetch the JAR file or not. The JAD file is used by the application manager to advertise themidlet suites. It provides the information of the JAR file contents. The MIDlet has a life cycle. This life cycle includes all different states the MIDlet can be in. The transition from one state to another can be triggered form within the MIDlet itself or externally form the application manager. Figure 3 depicts the life cycle of a MIDlet. 3
Constructed Paused User ends MIDlet/ MIDlet calls destroyapp() Destroyed Active Figure 3: MIDlet life cycle [adapted from [4]) When the MIDlet is constructed, it first enters the paused state. If error occurs during the execution of the MIDlet, the MIDlet is destroyed. The application manager can invoke the startapp() method to cause the MIDlet to enter the active state. The pauseapp() can bring back the MIDlet to paused state. The application manager can invoke destroyapp() method to terminate the MIDlet. 3. Development Process This section describes the Java ME application development process and the next section discuss the deployment process. To develop a MIDlet, development softwares are required. These include software development kits (SDKs), integrated development environments (IDEs), and compilers. The next subsections look into these tools. 3.1 Software Development Kits A SDK is a set of development tools that helps for the development of software applications. The SDK provides the developers with: The MIDP APIs Documentation Emulators and debugging support and Example applications There are various open-source SDKs available for developers. Nokia has developed the SDK for both series 40 platform and S60 platform. Java Platform Micro Edition Software Development Kit which includes Java Wireless Toolkit for CLDC is also available for download. 4
3.2 IDEs The SDKs can be integrated into IDEs. The most common IDEs in java programming are Java opensource NetBeans and Eclipse. If NetBeans is used for the JME development, Java mobility pack plug-in has to be added. The same goes for the eclipse, EclipseMe plug-in has to be added. 3.3 Compilers To compile the Java bytecode classes, the compiler is required. The Java Development Kit (JDK) need to be installed to have access to the Java compiler and the application for creating Java Archive files (jar.exe). The software is available for download on sun website. 3.4 Building an Application for MIDP When building a JME application, the.java source files and.jad files are the only files that have to be provided by the developer. In building the java application, the first step is to compile the java source files using the JDK compiler. This compiling produces the java bytecode classes which are.class files. The actual MIDlet (deployable in the mobile device) is created by packaging the classes in to a jar file and also the accompanying jad file is provided. The last step of the build process is preverifying. This is to check whether the bytecode classes are valid and safe. 4. Deployment of the Java ME application Java ME applications can be deployed in to a device in several ways, using a cable connection, Bluetooth, SMS Push, or the standard Over The Air or OTA method. OTA is the most common way of deploying the MIDlets to the device. With this delivery method, MIDlets developers host their MIDlets on the web server and provide a link to them. A user accesses the link to fetch the MIDlets to a mobile device. 5
Mobile device 1. User browses the web 2. User click the link to fetch.jad 3. Server sends.jad 4. User requests installation of midlets web server 5. Server delivers the.jar Figure 4: OTA delivery method (adapted from [4]) 5. Conclusion This report covered briefly the Java ME platform. It first, looked into the basics of Java ME platform, concentrating more on the concepts needed for mobile gaming. It then discusses the tools necessary to develop a Java ME application, and finally it discussed how to deploy the same application in to a real mobile device. References [1] Hammer, C. (2007). Creating Mobile Games: Using Java ME Platform to Put the Fun into Your Mobile Device and Cell Phone. US: Apress. [2] Java ME for Nokia Platforms E-learning. http://www.forum.nokia.com/technology_topics/development_platforms/java.xhtml [last accessed 22/04/2010] [3] Muchow, J.W. (2001). Core J2ME Technology & MIDP.US: Prentice Hall PTR [4] Topley, K. (2002). Java Java in a Nutshell. O'Reilly 6