The JavaME Frequently Asked Questions List

The JavaME Frequently Asked Questions list is a compilation of questions that are asked frequently by people using Java 2 Micro Edition .

Maintained by:

Table of Contents

  1. General questions
    1. What is JavaME (formerly called Java 2 Micro Edition)?
    2. What is a configuration?
    3. What is a profile?
    4. Can I use more than one profile at a time?
    5. What devices are currently JavaME-enabled?
    6. Where does PersonalJava fit into JavaME?
    7. I've ported the KVM/CVM to [some platform]. Can I distribute/sell my port?
    8. What are the minimum fields that must be present in a MIDlet suite's manifest?
    9. What are the minimum fields that must be present in a JAD file?
    10. I've heard the term J2ME, but not JavaME. What's JavaME?
  2. Developer Community
    1. Are there any JavaME-specific newsgroups, discussion forums or mailing lists?
    2. Where can I find archives for [some] mailing list on JavaME-related topics?
  3. The Connected Limited Device Configuration
    1. What are the minimum requirements for the CLDC?
    2. I want/need to use native methods. How can I do this?
    3. Does the CLDC support floating point operations?
  4. The Mobile Information Device Profile
    1. What is the MIDP?
    2. What is the current version of the MIDP specification?
    3. What does the acronym LCDUI stand for?
    4. Is MIDP available for the Palm OS?
    5. I don't have Java installed in /usr/local/java/jdkx.xx/x86/bin! How do I build the MIDP reference implementation?
    6. Can I access the address book on my PDA from my MIDlet?
    7. Does the MIDP support floating point operations?
  5. The Personal Digital Assistant Profile
    1. When will the PDA profile be available?
  6. The Connected Device Configuration
    1. What are the minimum requirements for the CDC?
  7. The Foundation Profile
    1. Why can't I find any UI classes in the Foundation profile?
  8. The Personal (and Personal Basis) Profile
    1. What is the Personal Profile?
    2. What is the difference between the Personal Profile and the Personal Basis Profile?
    3. I'm not using RedHat Linux. How do I build the reference implementation?
  9. Device Communications
    1. What is the Generic Connection Framework?
    2. I want to create a TCP/UDP/other connection with a server. Can I do this with MIDP?
    3. How do I create a server socket with the GCF?
    4. Can I dial a telephone number from my MIDlet?
    5. Can I determine the phone number from my MIDlet?
    6. When I'm using HTTP connections, I get the message 'java.io.IOException: exceeded the configured maximum number of connections'. Why?
    7. Can I determine the IP address for my device with my MIDlet?
    8. How do I setup persistent HTTP connections with a server?
    9. Then how do I tell the device I don't want to maintain persistent connections?
    10. Then can I re-use the same HttpConnection object more than once?
    11. Can I send SMS/MMS messages from my MIDlet?
  10. User Interfaces
    1. Can I create new form elements?
    2. I can create an Image from an array of bytes. Can I do the reverse and get an array of bytes from an Image?
    3. How do I get notification of high level key events from within a Form, TextArea or List within the MIDP?
    4. Can I highlight text in my TextField or TextBox object, or in a StringItem on a form?
    5. Can I assign Command objects to specific soft keys?
    6. When I run my MIDlet in the emulator, my image loads fine. But, when I run on a device, the image isn't displayed.
  11. Security
    1. Can I load a class from outside of my MIDlet suite?
  12. Runtime Activities
    1. How do I read a file from my JAR?
    2. How can I tell my device to automatically load my MIDlet when [something] happens?
    3. What happens to my threads when my MIDlet is suspended?
    4. What system properties are available to determine the device type at runtime?
    5. I would like to get the physical location of the handset. Is this possible?
  13. Developing Software For JavaME
    1. What are the minimum tools I need to begin development?
    2. What would a minimal ANT build.xml file look like?
    3. Where can I find the various reference implementations for J2ME configurations and profiles?
    4. I installed the Sun Wireless Toolkit. Why can't I run the sample MIDlets?
    5. What would the MIDP equivalent of Hello World! look like?
    6. When I attempt to obfuscate my MIDlet suite, Retroguard dies. Why?
    7. When I preverify my classes, I get the message "Class loading error: Bad major version number". Why?
    8. How do I use JDWPI to debug a MIDlet running in the Wireless Toolkit's emulator?
    9. How can I see debugging output from my Motorola iDEN phone?
    10. How do I add images and other resources to my project in the Wireless Toolkit?
  14. Writing games using JavaME
    1. Is there an editor to help me build the tiled layers for my game backgrounds?
  15. Provisioning A Device
    1. How do I download my MIDlet suite onto my cell phone or wireless device?
    2. What are the MIME types for JAR and JAD files?
    3. I want to test my MIDlet suite on my PC. What can I use?
    4. I keep getting the message 'invalid file' when trying to install my MIDlet suite. What's the problem?
  16. Motorola-Specific Questions
    1. How do I determine the firmware version of my iDEN phone?
    2. How do I determine the firmware version of my V-series phone?
    3. How do I handle incoming phone calls from Java?
    4. How do I make my application permanent on a Motorola handset?
    5. I'm getting the error message 'Invalid File' when downloading to a Motorola handset. Why?
  17. Nextel-Specific Questions
    1. What do the letters NXTL stand for on the RIM Blackberry?
  18. Nokia-Specific Questions
    1. How do I install software onto my Nokia handset?
    2. How do I determine the firmware version of my Nokia phone?
  19. Samsung-Specific Questions
    1. On my Samsung A600 my MIDlet never gets notified when the user presses the END key.
  20. Sony/Ericsson-Specific Questions
    1. When my app tries to make a network connection it freezes until I press a button.
  21. SprintPCS-Specific Questions
    1. I have a JAR/JAD that works fine in the emulator. But, when I download to my Sprint phone, I get a 90x error, and invalid descriptor message and the JAR/JAD won't download. Why?
    2. I followed the sugggestions above for fixing my JAR/JAD, but I still can't download them to my phone. Why?
    3. What are the sound APIs for SprintPCS's VM?
  22. T-Mobile-Specific Questions
    1. Sometimes my T-Mobile handset has Internet connectivity and sometimes it doesn't. Why?
  23. Vodafone-Specific Questions
    1. What does the MIDxlet-Resident JAD property represent?

  1. General questions
    1. What is JavaME (formerly called Java 2 Micro Edition)?

      To quote Sun's website:

      A highly optimized Java runtime environment, JavaME TM technology specifically addresses the vast consumer space, which covers the range of extremely tiny commodities such as smart cards or a pager all the way up to the set-top box, an appliance almost as powerful as a computer.

      Basically, JavaME is an umbrella term that refers to the collection of virtual machines, APIs and related elements that provide Java to handheld and embedded computing devices.

      Table of Contents
    2. What is a configuration?

      A configuration defines a virtual machine and the minimum APIs that must be present. In defining the virtual machine, the configuration specifies the minimum amount of memory that must be present as well as the minimum processor type and speed.

      Table of Contents
    3. What is a profile?

      A profile refers to the APIs for a specific domain. For example, the MIDP (Mobile Information Device Profile, description below ) defines the APIs that are made available for pervasive computing devices such as mobile phones, wireless PDAs and similar devices.

      Table of Contents
    4. Can I use more than one profile at a time?

      Yes, provided that the virtual machine and device supports the functionality for the additonal profile. For example, OEMs can provide their own profiles in addition to the MIDP to allow MIDlets to access device-specific features of their device, such as the information contained in the SIM card on a phone. However, if such a profile were provide by an OEM such as Nokia, this profile wouldn't be portable to other devices, such as Motorola.

      Another point to bring up is that, in order to use an optional API, it must already be present on the targeted device. For example, the MobileMedia API defines APIs for accessing such elements as the digital camera on a device. Developers can use these APIs to write camera-aware applications. However, merely writing an application against these APIs and loading the application on a device will not give you access to the camera. The APIs for the optional profile must be supported by the virtual machine itself as well. If support is not built into the virtual machine, then those optional features will not be available.

      Table of Contents
    5. What devices are currently JavaME-enabled?

      A list of devices can be found here .

      Table of Contents
    6. Where does PersonalJava fit into JavaME?

      PersonalJava was a previous implementation of Java for pervasive devices, based on Java 1.1. It is unrelated to JavaME. However, the Personal profile will fill the vacancy left by PersonalJava.

      Table of Contents
    7. I've ported the KVM/CVM to [some platform]. Can I distribute/sell my port?

      NOTE: The FAQ maintainers are not lawyers and this answer should not be construed as legal advice. With this understood, you may read the following as our possibly incorrect interpretation of the licensee agreement.

      When you downloaded the reference implementation, you agreed to the Sun Community Source License, which forbids you from distributing the source code for the reference implementation to anybody not also a licensee (section d, part i). You can only distribute binaries for evaluation purposes and cannot sell the ported VM (section d, part ii).

      Table of Contents
    8. What are the minimum fields that must be present in a MIDlet suite's manifest?

      The manifest must contain at least the following fields:

      • MIDlet-Name *
      • MIDlet-Version *
      • MIDlet-Vendor *
      • MIDlet-# (where # is the MIDlet number, one for each MIDlet)
      • MicroEdition-Profile
      • MicroEdition-Configuration

      * Value must exactly match those present in the JAD file.

      Table of Contents
    9. What are the minimum fields that must be present in a JAD file?

      A Java Application Descriptor must contain, at the minimum, the following fields:

      • MIDlet-Name *
      • MIDlet-Version *
      • MIDlet-Vendor *
      • MIDlet-Jar-URL
      • MIDlet-Jar-Size

      * Value must exactly match those present in the manifest.

      Table of Contents
    10. I've heard the term J2ME, but not JavaME. What's JavaME?

      At JavaOne 2005, Sun announced a new naming convention for Java technologies . With this change, the micro-edition technologies were renamed to be Java ME, dropping the "2" in the name to avoid confusing customers or building an expectation for some future J3ME.

      Table of Contents

  2. Developer Community
    1. Are there any JavaME-specific newsgroups, discussion forums or mailing lists?

      There are several, infact.

      NAME URL
      comp.lang.java.programmer comp.lang.java.programmer
      CLDC-FEEDBACK http://archives.java.sun.com/cldc-feedback.html
      KVM-INTEREST http://archives.java.sun.com/kvm-interest.html
      J2ME-CDC-INTEREST http://archives.java.sun.com/j2me-cdc-interest.html
      Forum Nokia http://www.forum.nokia.com
      Howard Forums http://www.howardforums.com

      Table of Contents
    2. Where can I find archives for [some] mailing list on JavaME-related topics?

      The following is an incomplete list of archives where past messages are stored for some JavaME-related mailing lists:

      Table of Contents

  3. The Connected Limited Device Configuration
    1. What are the minimum requirements for the CLDC?

      For a device to support the CLDC, it must have at minimum:

      • 16-/32-bit RISC/CISC processor
      • 160k of memory (128k of which is for the VM and APIs)
      • some form of network connectivity

      Table of Contents
    2. I want/need to use native methods. How can I do this?

      The simple answer is: you can't . JNI is not available within the resource constrained KVM.

      Some people will then bring up the KNI as an alternative/solution. This is, however, an incorrect answer and not a solution. The KNI is a Sun-specific porting layer, introduced into the reference implementation for the MIDP 2.0 and the CLDC 1.0.4. The purpose of this layer is to make porting these and future reference implementations to new platforms, and cannot be used as a means of linking native code at runtime.

      Table of Contents
    3. Does the CLDC support floating point operations?

      The CLDC 1.0 specification does not support floating point math. However, support for floating point math was introduced with the CLDC 1.1 specification .

      If you're working with a device that is built on the CLDC 1.0 specification and you need floating point math capabilities, you can download and use the MathFP library.

      Table of Contents

  4. The Mobile Information Device Profile
    1. What is the MIDP?

      The MIDP defines a set of APIs for mobile devices, such as cell phones and low-end PDAs (higher-end PDAs will better benefit from more powerful profiles such as the Personal Profile ).

      Table of Contents
    2. What is the current version of the MIDP specification?

      There are currently two versions of the MIDP specification: version 1.0 and version 2.0 (reference to as MIDP-NG or MIDP Next Generation). The 1.0 specification was the first profile released under the JavaME umbrella in 2000. The 2.0 specification was released in 2002 and addressed many of the shortcomings of the original specification. The 2.0 specification is also backwards compatible with 1.0.

      Table of Contents
    3. What does the acronym LCDUI stand for?

      There are several sources of conflicting information on this subject. This link claims that it stands for "Limited Connected Device UI", while this link claims that it stands for "Liquid Crystal Display UI", and JavaME Enterprise Development claims it stands for "Least Common Denominator UI".

      So, I went to the source (or, more exactly, I asked a question in the KVM-INTEREST mailing list and received a response) and asked for the definition. What I was told was:

      ...I emailed Jim [Jim Van Peursem] (MIDP 2.0 lead). He looked through his notes. He says that in Mark V. [Mark VandenBrink] (MIDP 1.0 lead) and Roger R's [Roger Riggs] MIDP 1.0 book, Mark calls it "Limited Connected Device" UI.

      I trust this as the ultimate source for the information.

      Table of Contents
    4. Is MIDP available for the Palm OS?

      In June, 2003, Palm announced an alliance with IBM to release IBM's WebSphere Micro Environment on their Tungsten line of handheld devices.

      You can also download MIDP4Palm , which was the first MIDP platform released for the PalmOS.

      Read this for a note on the previously announced PDA Profile .

      Table of Contents
    5. I don't have Java installed in /usr/local/java/jdkx.xx/x86/bin! How do I build the MIDP reference implementation?

      There are several macros used by the makefile to determine where elements exist on the system. One, ALT_BOOTDIR , tells the makefile where Java is installed. By redefining this macro in the commandline to point to where Java's installed on your system, the build should complete (barring any other differences between your system and the expections of the makefile).

      Assuming your JDK is installed in /usr/lib/j2se/1.3 (the default for Debian with JDK 1.3 installed), you would use the following commandline:

       make ALT_BOOTDIR=/usr/lib/j2se/1.3
      				

      Table of Contents
    6. Can I access the address book on my PDA from my MIDlet?

      Not with MIDP. However, there are APIs available in the PDA Optional Packages for the JavaME Platform that will give you access to this information.

      Table of Contents
    7. Does the MIDP support floating point operations?

      Since the MIDP is build on top of the CLDC , this question is more appropriately answered in the CLDC section here .

      Table of Contents

  5. The Personal Digital Assistant Profile
    1. When will the PDA profile be available?

      The PDA Profile is now called the PDA Optional Packages for the JavaME Platform and consists of two separate, optional packages:

      • Personal Information Manager APIs - Enables the developer to access the native personal information management data that resides on the device, including the address book, calendar, and to-do lists.
      • FileConnection APIs - Gives the developer access to file systems on the device, such as external memory cards.

      These APIs will be implemented by the VM vendor on other JavaME profiles, such as the MIDP and Personal (and Personal Basis) Profile , and will enhance the CLDC .

      Table of Contents

  6. The Connected Device Configuration
    1. What are the minimum requirements for the CDC?

      For a device to support the CDC, it must have at minimum:

      • 32-bit RISC/CISC processor
      • 2M RAM
      • some form of network connectivity

      Table of Contents

  7. The Foundation Profile
    1. Why can't I find any UI classes in the Foundation profile?

      The Foundation profile, when used by itself, is intended for embedded and headless devices; i.e., devices that have no user interface, such as routers and gateway devices.

      There are other profiles, such as the Personal Profile , that are intended to run on top of the Foundation profile.

      Table of Contents

  8. The Personal (and Personal Basis) Profile
    1. What is the Personal Profile?

      The Personal Profile is the JavaME replacement for PersonalJava .

      Table of Contents
    2. What is the difference between the Personal Profile and the Personal Basis Profile?

      The Personal Basis Profile ( JSR-129 )defines a minimal set of user interface APIs. The Personal Profile ( JSR-62 ) builds on the APIs from the Personal Basis Profile.

      The Personal Profile is intended to be the next step in the migration path from PersonalJava and, as such, needs to support the full feature set of PersonalJava. The Personal Basis Profile is intended to address devices less capable than those targeted by the Personal Profile, providing a scaled down API set.

      Table of Contents
    3. I'm not using RedHat Linux. How do I build the reference implementation?

      The build environment requires a few macros be defined at the commandline to tell it the locations for your JDK, the shell to use and the location for specific GNU tools. The following table lists the macros and the values necessary to perform the build on a Debian Linux system:

      MACRO NAME DESCRIPTION VALUE ON DEBIAN
      JDK_HOME The root of your JDK installation. /usr/lib/j2se/1.3
      SHELL The path to the shell used for executing commands. /bin/bash
      CVM_GNU_TOOLS_PATH The location for the standard GNU toolset. /usr/bin

      Table of Contents

  9. Device Communications
    1. What is the Generic Connection Framework?

      The Generic Connection Framework is the paradigm used for creating javax.microedition.io.Connection objects that support different protocols. A URI defining the protocol and remote end-point for the network connection is passed to the javax.microedition.io.Connector class via one of the open() methods and a javax.microedition.io.Connection -type object is returned, ready to connect to the end-point.

      Table of Contents
    2. I want to create a TCP/UDP/other connection with a server. Can I do this with MIDP?

      Yes, if the device supports such a connection. The only required protocol is HTTP, but the OEM can provide other protocols as well.

      Table of Contents
    3. How do I create a server socket with the GCF?

      You don't. With the the GCF , there is no support for server sockets. However, you can instead create a javax.microedition.io.StreamConnectionNotifier instance and invoke its acceptAndOpen() API. The following snippet demonstrates how to do this:

       public void waitForConnection() { // change the port number to be
      					whatever is appropriate for your application
      					StreamConnectionNotifier server = (StreamConnectionNotifier
      					)Connector.open("serversocket://:10000"); StreamConnection
      					conn = server.acceptAndOpen(); // do something useful with the new
      					connection }
      				

      Table of Contents
    4. Can I dial a telephone number from my MIDlet?

      The MIDP 1.0 specification does not provide an API for doing this. The OEM, though, is free to add any additional profiles they wish to the mix.

      The MIDP 2.0 specification includes platformRequest(String) method in the javax.microedition.midlet.MIDlet class. The telephone number can be passed in the form tel:<number> as defined in RFC 2806 .

      Table of Contents
    5. Can I determine the phone number from my MIDlet?

      The MIDP 1.0 specification does not include APIs for accessing the phone number or SIM information for the device on which it's running. OEM's are free to add additional APIs for accessing this information, though.

      The MIDP 2.0 specification includes platformRequest(String) which OEMs can use to provide this information if they so choose.

      Table of Contents
    6. When I'm using HTTP connections, I get the message 'java.io.IOException: exceeded the configured maximum number of connections'. Why?

      The answer involves the java.io.InputStream and java.io.OutputStream objects related to the javax.microedition.io.HttpConnection object in use. If you're using either input or output streams, it is necessary to close them after you've finished with the connection. Otherwise, the underlying implementation is most likely keeping the javax.microedition.io.Connection object open. Simply call close() on all related streams and it should solve the problem.

      Also, be sure you're not using persistent connections if you're going to multiple servers during an application's sessions.

      Table of Contents
    7. Can I determine the IP address for my device with my MIDlet?

      No. Not all MIDP devices use IP-based networking, and the MIDP expert group didn't include an API for determining the address for those devices that do.

      Table of Contents
    8. How do I setup persistent HTTP connections with a server?

      In HTTP 1.1, persistent connections are the default behavior required by the specification. So, no special coding is required to suggest to the device that the underlying connection should be maintained between HTTP requests.

      See the next question for information on how to turn off persistent connections.

      Table of Contents
    9. Then how do I tell the device I don't want to maintain persistent connections?

      When setting up the connection object, set the "Connection" property to "close". This will tell the server to tear down the connection after the response has been set.

       HttpConnection conn = (HttpConnection
      					)connector.open("http://foo.com/index.jsp"); // set the
      					Connection property if(!persistent)
      					conn.setRequestProperty("Connection","close");
      				

      Table of Contents
    10. Then can I re-use the same HttpConnection object more than once?

      No, you cannot use the same object more than once. The HttpConnection object represents exactly ONE round-trip connection with the server and, as such, cannot be used for transmitting data more than one.

      The connection object can exist in one of three states: 1) Setup , 2) Connected and 3) Closed and, when it moves to a new state, it can not return to a previous state. So, when data is sent to the server, the connection has moved from the setup state into the connected state. In the connected state, the connection can only receive data from the server and cannot send any more data to the server. When the incoming data has been received and the InputStream objects closed (or the connection itself is closed, but I'm assuming you were diligent and closed your input and output streams first <g>), the connection moves into the closed state and no further data can be read from the connection. Any attempt to use methods from a previous state on a connection object will result in an IOException being thrown.

      If what you're trying to accomplish is persistent connections, please see this frequently asked question .

      Table of Contents
    11. Can I send SMS/MMS messages from my MIDlet?

      You can send SMS messages, provided the device hosting your MIDlet supports JSR-120 , the Wireless Messaging API 1.0. If your device supports version 2.0 of this specification, then you will be able to send MMS messages as well.

      Table of Contents

  10. User Interfaces
    1. Can I create new form elements?

      Not with MIDP 1.0. According to the specification, javax.microedition.lcdui.Form only has APIs for appending elements using an instance of java.lang.String (which is a shortcut to creating an instance of javax.microedition.lcdui.StringItem , javax.microedition.lcdui.Image (which is a shortcut to creating an instance of javax.microedition.lcdui.ImageItem or javax.microedition.lcdui.Item . There's no way to create a new subclass of javax.microedition.lcdui.Item since the single abstract method, paint() , has package (default) protection. It is also against the licensing agreement (per section e, subsection iv) to create a new subclass in the javax.* package hierarchy. Finally, even if the licensing agreement were ignored, most VMs will ignore any class in the java[x].* hierarchy.

      In MIDP 2.0, the class javax.microedition.lcdui.CustomItem was introduced. Subclassing this class will allow you to create new elements that can be added to forms.

      Table of Contents
    2. I can create an Image from an array of bytes. Can I do the reverse and get an array of bytes from an Image?

      Unfortunately, no. There's no API available for extracting anything more than the image's width, height, an instance of javax.microedition.lcdui.Graphics and mutability.

      With the MIDP 2.0 you can get the raw bytes from an instance of javax.microedition.lcdui.Image through the getRGB() API.

      Table of Contents
    3. How do I get notification of high level key events from within a Form, TextArea or List within the MIDP?

      The high level user interface APIs in javax.microedition.lcdui do not give you access to the low level key events. These events are only available to classes which extend javax.microedition.lcdui.Canvas .

      There is an alternative, though it may not meet the requirements above. The javax.microedition.lcdui.ItemStateListener interface defines a contract for objects that will be notified of state changes within a javax.microedition.lcdui.Form object. However, there is no specific set of conditions under which these notifications are sent; i.e., it is up to the device/VM vendor to decide when and if notifications will be sent. So, notifications will vary greatly between different devices and VM implementations.

      Table of Contents
    4. Can I highlight text in my TextField or TextBox object, or in a StringItem on a form?

      No. There is no way to mark up the text being displayed by these components.

      Table of Contents
    5. Can I assign Command objects to specific soft keys?

      No, you can't.

      When you create an instance of Command you can only specify a label, a command type and a priority. The MIDP implementation uses the type and priority of the commands to be displayed to determine how the commands will be presented to the user. It will also make a best effort to map keys to the appropriate button for that device; i.e., if the device normally displays OK buttons on the right side, then it will attempt to present your command of type Command.OK on the right side.

      Also, not all MIDs have softkeys. For example, the RIM Blackberry displays the Command s as menu items. On such a device, there's no concept of a softkey. Instead, on such devices, the implementation will use the priority of the Command s as well as their type in order to group and sort them prior to displaying them to the user. So, be sure that each command within each group has a unique priority.

      Table of Contents
    6. When I run my MIDlet in the emulator, my image loads fine. But, when I run on a device, the image isn't displayed.

      Verify that your image file is present in your MIDlet suite's JAR file and that it's JAR entry is the same as your code expects; i.e., if you're using Image.createImage("/foo.png") , then there must be a JAR entry named /foo.png or else the MIDP implementation will throw an IOException . Remember, also, that filenames are case sensitive and that you have to use the full entry name for the image.

      Table of Contents

  11. Security
    1. Can I load a class from outside of my MIDlet suite?

      No. The MIDlet is limited to only loading classes from within it's suite. This prevents hackers from loading dangerous classes. It also prevents a device from using precious bandwidth for loading classes over the air or via low-bandwidth network connections.

      Table of Contents

  12. Runtime Activities
    1. How do I read a file from my JAR?

      To read a file from your MIDlet suite's JAR file, use the java.lang.class.getResourceAsStream() API.

      Table of Contents
    2. How can I tell my device to automatically load my MIDlet when [something] happens?

      With MIDP 1.0, there's no way to automatically launch a MIDlet either at device startup or upon reception of some data.

      With MIDP 2.0, there's the concept of the push registry , which allows a MIDlet to register itself for network and timer initiated MIDlet activation. Take a look at the javax.microedition.io.PushRegistry class Javadocs for more details on using the push registry.

      Table of Contents
    3. What happens to my threads when my MIDlet is suspended?

      On most devices, the only thread that is suspended is the main application thread for the MIDlet. Any other thread that was started by the MIDlet will most likely (but not always) continue running.

      Table of Contents
    4. What system properties are available to determine the device type at runtime?

      The following system properties are available, as of MIDP 2.0, to help determine the type of device on which the MIDlet suite is running:

      microedition.platform Identifies the device type or host platform, or returns null if the value is undefined
      microedition.encoding The default character encoding.
      microedition.configuration The configuration this device has implemented.
      microedition.profiles The profiles this device has implemented.
      microedition.locale The current locale for the device. This value may be null .

      A list of properties is also defined here .

      Table of Contents
    5. I would like to get the physical location of the handset. Is this possible?

      To get the handset's location, you would have to have a handset that supports the Location API for JavaME . With this API you can get the location for the handset at runtime. Unless the OEM has implemented this API on the handset, you will not be able to determine the physical location of the device.

      Table of Contents

  13. Developing Software For JavaME
    1. What are the minimum tools I need to begin development?

      Minimally, you will need:

      • JDK version 1.3 or higher
      • the reference implementation for the targeted profile
      • the reference implementation for the targeted configuration
      • the ANT build utility (click here for an example build.xml file)

      The reference implementations provide the APIs for compiling the application. They also provide the preverifier, which performs the initial verification of the created byte code. This saves the device from having to perform initial verification, which can be resource expensive. It also inserts extra information into the byte code which is needed by the VM, but which is ignored by the J2SE VM, so compiled classes can be shared between JavaME and J2SE.

      This all said, I would now recommend instead that you download Sun's Wireless Toolkit 2.x or later , Eclipse 3.x or later and EclipseME . This gives the most complete environment for JavaME development for the price.

      Table of Contents
    2. What would a minimal ANT build.xml file look like?

      I've removed the ANT example from the FAQ. It is recommended that, rather than using this example for most tasks, you use the Antenna suite of ANT tasks. With Antenna, all of the more awkward tasks, such as preverification, obfuscation and the launching of emulators, have already been taken care of for you and are far easier to integrate into your build environment.

      Table of Contents
    3. Where can I find the various reference implementations for J2ME configurations and profiles?
      • Download the CLDC reference implementations here .
      • Download the MIDP reference implementations here .
      • Download the CDC reference implementations here .
      • Download the Foundation Profile reference implementations here .
      • Download the Personal Basis Profile reference implementations here .
      • Download the Personal Profile reference implementations here .
      • Download the RMI Optional Packages reference implentations here .

      Table of Contents
    4. I installed the Sun Wireless Toolkit. Why can't I run the sample MIDlets?

      This answer assumes you're running in a Unix/Linux environment, and installed using the root account.

      When the toolkit was installed, it created the directory structure with root as owner (assuming you didn't install the product as yourself in your home directory, or one to which you have write access). The file access permissions for the tree are root.[ staff on my system] rwxr-sr-x . As you can tell from this, only members of the owning group can read the directories where the toolkit was installed. In addition, only root can write to the directory tree. So, unless you are running the toolkit as root (not a very good practice at all) you will not be able to run any of the samples for the toolkit until you make some changes to the directory structure.

      The best thing to do is to go into the JavaMEwtk/apps directory and change the permissions to allow the owning group to write to the directories as well. From the installation directory, execute the command:

       find apps -type d -exec chmod 775 {} \;
      				

      This will descend into each directory and change the permissions to allow members of the owning group to write to the directories, but will not allow anybody to change the files in the directories. This way, the source code will still be read-only, but users will be able to compile and execute them.

      Table of Contents
    5. What would the MIDP equivalent of Hello World! look like?
       import javax.microedition.lcdui.Command; import
      					javax.microedition.lcdui.CommandListener; import
      					javax.microedition.lcdui.Display; import
      					javax.microedition.lcdui.Displayable; import
      					javax.microedition.lcdui.Form; import
      					javax.microedition.midlet.MIDlet; public class HelloWorld
      					extends MIDlet implements CommandListener { public HelloWorld() { }
      					public void startApp() { Form form = new Form("Hello world!");
      					form.addCommand(new Command("Exit",Command.EXIT,1));
      					form.setCommandListener(this);
      					Display.getDisplay(this).setCurrent(form); } public void
      					pauseApp() { } public void destroyApp(boolean unconditional) { }
      					public void commandAction(Command c,Displayable d) {
      					if(c.getCommandType() == Command.EXIT) { notifyDestroyed(); } } }
      				

      Table of Contents
    6. When I attempt to obfuscate my MIDlet suite, Retroguard dies. Why?

      It is a problem with the way obfuscation works in Java. Most obfuscators will begin altering the bytecode by traversing the methods and classes used by your MIDlet, and then examines the methods and classes used by those methods, to obfuscate the code. When RetroGuard hits a native method (for example, one within the MIDP API that's implemented in the KVM rather than in Java code), it cannot handle the situation and returns an error.

      If you're using an archive or subdirectory in your classpath for RetroGuard that contains a working version of the MIDP API, RetroGuard is hitting one or more of the above-mentioned native code references. It is this that is causing the failure during obfuscation.

      The solution is to use the file emptyapi.zip , which comes with the Wireless Toolkit. This archive provides all of the public interfaces used by the MID Profile without any of the underlying implementation code or references to any native methods.

      Table of Contents
    7. When I preverify my classes, I get the message "Class loading error: Bad major version number". Why?

      My guess is that you're using JDK version 1.4 or higher. The problem is that the byte code format generated by the 1.4 and later compiler is incompatible with earlier versions of the preverify executable that you're using.

      To fix the problem, upgrade your toolkit to the latest version and see if that fixes the problem. If you're using the latest tool, or if your tool vendor hasn't upgraded their tools, then you can use the following commandline:

       javac {whatever arguments you normally use} -target 1.1 {your more
      					arguments}
      				

      This will cause the compiler to produce pre-1.4 byte code.

      If you're using J2SDK 5, then you'll want to add the following commandline argument instead:

      javac {whatever arguments you normally use} -source 1.2 -target 1.2
      				

      Table of Contents
    8. How do I use JDWPI to debug a MIDlet running in the Wireless Toolkit's emulator?

      To access the emulator using sockets, start the emulator and include the following command line argument:

       -Xrunjdwp:transport=dt_socket,address=[the local
      					port],server=y,suspend=y
      				

      replacing [the local port] with an available port number. Then, give the same port number to your debugger in order to connect to the emulator.

      To access the emulator using shared memory, start the emulator and, instead of specifying a port, specify the name of the shared memory page using the following command line argument:

       -Xrunjdwp:transport=dt_shmem,address=[the shared memory
      					page],server=y,suspend=y
      				

      replacing [the shared memory page] with a unique memory pagename. Then give the same name to your debugger in order to access the shared memory.

      Table of Contents
    9. How can I see debugging output from my Motorola iDEN phone?

      You need to connect your iDEN phone to a serial port on your computer using a data cable. Then, from a terminal application (set to 19200bps , issue the following command:

       AT+WS46=252;+WS45=0;+IAPPL=2;D
      				

      This will cause all output sent to System.out and System.err to be sent to the serial port and, finally, to your terminal application.

      Table of Contents
    10. How do I add images and other resources to my project in the Wireless Toolkit?

      You copy these and any other files into the res (short for resources) directory beneath your application's directory. Within your code you would refer to them using "/res/[filename]".

      Table of Contents

  14. Writing games using JavaME
    1. Is there an editor to help me build the tiled layers for my game backgrounds?

      Yes, there are a few.

      For Windows, there is Tile Studio , World Creator and Mappy .

      Table of Contents

  15. Provisioning A Device
    1. How do I download my MIDlet suite onto my cell phone or wireless device?

      This depends on the device in question. There are two ways to put a MIDlet suite onto a device:

      • Over-the-air (OTA) provisioning
      • Provisioning via data cable

      Over-the-air provisioning is when the application is downloaded from a web or portal site and installed onto the device. An overview of OTA provisioning can be found here . The basic flow is that the device retrieves the JAD file from a web or portal site and determines whether the MIDlet suite can install onto the device. If the suite is acceptable (i.e., it's new to the device, or it's the same or more recent version of an installed suite, and it's not too big [if there's a size restriction imposed by the carrier]) then the user is prompted if they want continue with the installation. If the user accepts, then the MIDlet suite is downloaded over the air and installed onto the device.

      Provisioning via a data cable is more direct in its approach. Software is provided by the OEM and is used to connect to the device normally via a serial or USB cable connected to the device, such as the cradle for a Palm or RIM, or the data cable for the Motorola phones. Using this software, the developer browses the local file system and selects the JAR and JAD files to install onto the device. The software then negotiates a connection with the device and uploads the MIDlet suite.

      Table of Contents
    2. What are the MIME types for JAR and JAD files?

      In order for a web server to host a MIDlet suite, it has to be configured to send the property content types when sending a JAR and JAD file. To do so, the following MIME types must be configured for the server:

      FILE TYPE EXTENSION MIME TYPE
      JAR .jar application/java-archive
      JAD .jad text/vnd.sun.j2me.app-descriptor

      To set these values in Apache2, add the following lines to your /etc/apache2/apache2.conf file:

      AddEncoding application/java-archive jar

      AddEncoding text/vnd.sun.j2me.app-descriptor jad

      Table of Contents
    3. I want to test my MIDlet suite on my PC. What can I use?

      Well, the first answer is to use the emulators that ship with Sun's Wireless Toolkit , being sure to grab the appropriate version for the MIDP version you're targeting.

      Additionally, nearly every device manufacturer has their own emulators available for their devices. Motorola, Nokia and RIM even ship either complete IDEs (such as Metrowerks Code Warrior and Nokia's Developer Suite for J2ME .

      For those looking for a Java-based solution, there is an (incomplete at this time) emulator written in Java called ME4SE that is an emulator built of Java 2 Standard Edition. It includes the ability to run the MIDlet within an applet in a user's web browser. There is also the MicroEmulator project which has built a MIDP emulator using the JDK 1.1. This would allow MIDlets to be demonstrated from within older browsers.

      Another tool that provides a pure Java environment for emulator a MID is the MPowerplayer SDK . To quote their website:

      The mpowerplayer software developer kit includes the mpowerplayer as a standalone application. It's a pure Java emulator implementing MIDP 2.0 and MMAPI, suitable for integration with your favorite environment and IDE.

      Table of Contents
    4. I keep getting the message 'invalid file' when trying to install my MIDlet suite. What's the problem?

      There are several potential reasons for this problem showing up:

      • You have missing or incorrectly formatted mandatory attributes in your JAD file. For Motorola phones, the limitations of the Mandatory attributes are:
        • MIDlet-Name (max 32 character)
        • MIDlet-Version MIDlet-Vendor (max 32 characters)
        • MIDlet-JAR-URL (up to 256 characters)
        • MIDlet-JAR-Size (must match JAR file size in bytes)
      • The version of the MIDP and/or CLDC specified is not supported by the handset itself
      • The attributes that are in both the JAD file and the MIDlet suite's manifest do not match. Be sure to check the files with a hex editor to ensure that one or the other does not have a special character in it
      • One or more classes in the MIDlet suite refer to classes not found on the handset; for example, your MIDlet suite uses the Wireless Messaging APIs but those APIs aren't present on the handset.
      • The value for the MIDlet-Data-Size (if used) exceeds maximum value for the handset (for Motorola V300,V400, V525, V500 and V600 this size is 512k, or 524,288 bytes).

      Table of Contents

  16. Motorola-Specific Questions
    1. How do I determine the firmware version of my iDEN phone?

      With your handset, press the following button sequence:

       # * [menu] [right navigation button]
      				

      Table of Contents
    2. How do I determine the firmware version of my V-series phone?

      On my V400 (and my V300 at work) I press the following sequence:

       * # 9 9 9 9 #
      				

      Although this same information is also available if you go to MENU -> Settings -> Phone Status -> Other Information , where each field is selectable individually.

      Table of Contents
    3. How do I handle incoming phone calls from Java?

      On the i730 it's:

       Settings -> Phone Calls -> Java App Control -> [your MIDlet]
      				

      Table of Contents
    4. How do I make my application permanent on a Motorola handset?

      ( NOTE: this is unverified by the FAQ maintainers)

      Enter the sequence "#*#159#*#" while in the Java menu on the phone. Then choose to mark the app as a "Permanent App". It will then not be uninstallable unless the user re-enters the key sequence and marks the app as uninstallable. Permissions for the app can also be set here as well.

      Table of Contents
    5. I'm getting the error message 'Invalid File' when downloading to a Motorola handset. Why?

      There are serveral possibilities:

      • Missing or incorrectly formatted mandatory JAD Attributes. The limitations of the Mandatory attributes are: MIDlet-Name (max 32 character), MIDlet-Version MIDlet-Vendor (max 32 characters), MIDlet-JAR-URL (up to 256 characters), MIDlet-JAR-Size (must match JAR file size in bytes)
      • MIDP or CLDC compile version of MIDlet is not supported by the handset.
      • JAD attributes do not match the Manifest in the JAR - check these files using a Hex Editior in case there are some "special" characters inserted in either file which do not appear in your text editor.
      • Class usage compiled into the MIDlet which does not exist in the handset.
      • MIDlet-Data-Size (if used) exceeds maximum value (v300,v400, v525, v500, v600) = 512k (524288 bytes).

      Table of Contents

  17. Nextel-Specific Questions
    1. What do the letters NXTL stand for on the RIM Blackberry?

      As your device connects to the network, you'll notice in the upper-right corner of the display the letters "NXTL". These letters will individually cycle through upper- and lower-case states before finally (hopefully) becoming all upper-case, which signals a good connection to the network.

      But, why does it do this? What do these characters mean? I have the answer. After having spent some time on the phone with Nextel's technical support I was given this explanation for what each character stands for:

      N Cellular network connectivity
      X Walky-talky feature connectivity
      T Packet data network connectivity
      L Network registration

      Table of Contents

  18. Nokia-Specific Questions
    1. How do I install software onto my Nokia handset?

      There are multiple ways to install sofware onto your Nokia handset:

      • Over-the-air provisioning
      • Via infrared connection or data cable
      • Via Bluetooth

      To install over-the-air, you need to have a data plan with your wireless carrier. For Series 40 and 60 phones, go to the Services screen and select Bookmarks Setup a link to your JAD file (or to the page hosting the JAD file) by selection Options and then New bookmark . Once it's setup, go back to the Bookmarks screen and click the call button (or click Options and then Go to ) to open the link. Then follow the prompts to download and install the MIDlet suite.

      To install via irDA, you need to have installed the appropriate PC Suite software from Nokia's website. Once installed, you can connect the handset to your PC and use the Application Installer too to deploy your application onto your handset.

      For Bluetooth installation, you need to first connect to your handset via Bluetooth. Then, simply push the JAR and JAD files onto the handset. You should receive a message stating that new files were received and you need only follow the prompts to complete the installation process.

      Table of Contents
    2. How do I determine the firmware version of my Nokia phone?

      With your handset, press the following key sequence:

       # * 0 0 0 0 *
      				

      Table of Contents

  19. Samsung-Specific Questions
    1. On my Samsung A600 my MIDlet never gets notified when the user presses the END key.

      The unverified answer (I've never talked with someone from Samsung) seems to be that, when the END key is pressed, the A600 does not notify the MIDlet but instead stops the VM itself from executing. So, rather than receiving a callback (either MIDlet.pauseApp() or Canvas.hideNotify() ) notification, your application will just stop .

      If you're writing a time-sensitive application, then you should probably put some sort of time checking into your code and attempt to detect such situations. In my case, I wrote a game that had the side-effect of the player losing on time when the END key was pressed. To solve the problem, I had my core loop grab the time when it started and the time when it was finished a single iteration. If that time value was greater than a normal update event, then it assumed the END key had been pressed and modified the game time accordingly.

      Table of Contents

  20. Sony/Ericsson-Specific Questions
    1. When my app tries to make a network connection it freezes until I press a button.

      If you're working in full-screen mode, what's happening is that the "Allow network access" prompt is being displayed but isn't visible since the app's controlling the entire screen. The workaround for this is to switch to non-full screen mode prior to making the first network access attempt, then switch back to full screen mode afterward.

      Table of Contents

  21. SprintPCS-Specific Questions
    1. I have a JAR/JAD that works fine in the emulator. But, when I download to my Sprint phone, I get a 90x error, and invalid descriptor message and the JAR/JAD won't download. Why?

      The reason is going to be either of both of the following elements missing from your JAD file: either there's no MIDlet-Data-Size entry (which is necessary) or your MIDlet-Jar-URL does not have the full URL for the JAR file; i.e., it has filename.jar instead of http://yourwebsite/filename.jar . SprintPCS phones require the full URL for your MIDlet suite in order to download and install it to your handset.

      Table of Contents
    2. I followed the sugggestions above for fixing my JAR/JAD, but I still can't download them to my phone. Why?

      This is related to Sprint's WAP gateway. It caches entries for increased performance, but at the expense of getting to updated material. Unfortunately, unless you have administrative rights to your webserver and can configure it to give content a short TTL, the only way you can get around this problem is to use a different name for the JAR and JAD everytime you upload a version to test.

      My (Darryl's) personal strategy when testing on sprint phones is to just use a rolling series of filenames; i.e., the first set I put on my server is a1.jar and a1.jad . After I've downloaded this, I delete the files and test. When I have to fix something and redeploy, I then deploy files a2.jar and a2.jad .

      When I've finally gotten the point where I'm satisfied with the code and ready to hand it over to QA and my product manager, then I finally deploy the files with the proper name.

      Table of Contents
    3. What are the sound APIs for SprintPCS's VM?

      To play sounds on a Sprint device, you need to first create an instance of the com.sprintpcs.media.Clip class, providing it with either the full path to the sound file in your JAR, or an array of bytes that comprise the sound file.

      Once you have a Clip , you then pass it to one of the com.sprintpcs.media.Player class's static methods:

      • play(Clip clip,int repeat) , which plays the clip for the specified number of repetitions, but will end the clip should another one be played
      • playBackground(Clip clip,int repeat) , which plays the clip for the specified number of repetitions. The sound will be paused when another sound is played, and will continue until that sound is completed.

      Table of Contents

  22. T-Mobile-Specific Questions
    1. Sometimes my T-Mobile handset has Internet connectivity and sometimes it doesn't. Why?

      This answer assumes two things:

      • You're in an area where there is no T-Mobile coverage, and
      • You're in an area where Cingular and at least one other carrier is present (such as North Carolina)

      If these assumptions are correct, then you need to manually select your network and choose Cingular . At least here in North Carolina, T-Mobile has no network coverage and so has a sharing agreement with Cingular. When I use a T-Mobile device, it sometimes selects AT&T rather than Cingular and will have no Internet connectivity. Simply switching it back to Cingular solves the problem, for me anyway.

      Table of Contents

  23. Vodafone-Specific Questions
    1. What does the MIDxlet-Resident JAD property represent?

      This indicates whether the MIDlet will remain active in memory (resident) in the background and able to process events.

      Table of Contents

This document was generated automatically using faq2html.xsl, by Darryl L. Pierce.
You may use the stylesheet for your own purposes, but this authorship notice MUST remain intact.