Sun J2ME Wireless Toolkit

 
 
The Sun J2ME Wireless Toolkit supports the development of Java applications that run on devices such as cellular phones, two-way pagers, and palmtops.

More information about the Sun J2ME Wireless Toolkit can be found at: http://java.sun.com/products/j2mewtoolkit/







Launching the emulator (WTK22) from the command line.



Information
The WTK emulator can be run from the command line.

Operating system used
Windows XP Home Edition Version 5.1 SP 2

Software prerequisites
Sun J2ME Wireless Toolkit 2.2

Procedure
  1. For example the Sun J2ME Wireless Toolkit 2.2 is installed on: C:\Tools\WTK22.

  2. Type: cd C:\Tools\WTK22\bin

  3. The emulator syntax is:

    emulator [arguments] <Application>

    More information about the emulator command line arguments, type:

    C:\Tools\WTK22\bin\emulator -help

    An overview of all the emulator commandline arguments can be found in the table below:

    ArgumentDescription
    -classpath, -cp The class path for the VM
    -D<property=value> Property definitions
    -version Display version information about the emulator
    -help Display list of valid arguments
    -Xverbose[:allocation | gc | gcverbose | class | classverbose | verifier | stackmaps | bytecodes | calls | callsverbose | frames | stackchunks | exceptions | events | threading | monitors | networking | all] enable verbose output
    -Xquery Query options
    -Xdebug Use a remote debugger
    -Xrunjdwp:[transport=<transport>, address=<address>,
    server=<y/n>,
    suspend=<y/n>]
    Debugging options
    -Xdevice:<device name> Name of the device to be emulated. The following devives can be entered:

    DefaultColorPhone
    DefaultGrayPhone
    MediaControlSkin
    QwertyDevice
    -Xdescriptor:<JAD file name>The JAD file to be executed
    -Xjam[:install=<JAD file url> | force | list | storageNames | run=[<storage name> | <storage number>] |
    remove=[<storage name> | <storage number> | all] |
    transient=<JAD file url>]
    Java Application Manager and support for Over The Air provisioning (OTA)
    -Xautotest:<JAD file url>Run in autotest mode
    -Xheapsize:<size> (e.g. 65536 or 128k or 1M) specifies the VM heapsize (overrides default value)
    -Xprefs:<filename> Override preferences by properties in file
    -Xnoagent Supported for backwards compatibility
    -Xdomain:<domain_name>Set the MIDlet suite's security domain


  4. Here below are a few examples how to use the emulator:

    • Run the emulator with a .jad URL path:

      C:\Tools\WTK22\bin>emulator -Xjam:install=
      https://www.mobilefish.com/customer/public/midlets/MobileStatus.jad


    • Run the emulator with a .jad file system path:

      C:\Tools\WTK22\bin>emulator -Xdescriptor:C:\mobilefish_web\MobileStatus.jad

    • To avoid OutOfMemory, the heapsize is increased:

      C:\Tools\WTK22\bin>emulator -Xheapsize:2M -Xdescriptor:C:\mobilefish_web\MobileStatus.jad

    • Select a device:

      C:\Tools\WTK22\bin>emulator -Xdevice:DefaultGrayPhone -Xdescriptor:C:\mobilefish_web\MobileStatus.jad

    • If additional classes are needed, specify a classpath:

      C:\Tools\WTK22\bin>emulator -classpath C:/lib/midlet.jar -Xdescriptor:C:\mobilefish_web\MobileStatus.jad

    • Debug:

      C:\Tools\WTK22\bin>emulator -Xdebug -Xrunjdwp:transport=dt_socket,address=2800, server=y,suspend=y -Xdescriptor:C:\mobilefish_web\MobileStatus.jad

    • Run the emulator with a .jad URL path:

      C:\Tools\WTK22\bin>emulator -Xautotest:
      https://www.mobilefish.com/customer/public/midlets/MobileStatus.jad




  5. A list of error messages generated by the emulator tool and a way to fix the problem:



    Error message:
    Error installing suite: Failed to download https://www.mobilefish.com/customer/MobileStatus.jar HTTP response code: 302

    Solution:
    • In the .jad file the wrong URL is entered in attribute MIDlet-Jar-URL


    Error message:
    Error installing suite (13): A required attribute is missing.

    Solution:
    • The attribute MIDlet-Name is missing in the .jad file.


    Error message:
    Error installing suite (14): A required attribute is missing.

    Solution:
    • The attribute MIDlet-Vendor is missing in the .jad file.


    Error message:
    Error installing suite (15): A required attribute is missing.

    Solution:
    • The attribute MIDlet-Version is missing in the .jad file.


    Error message:
    Error installing suite (18): A required attribute is missing.

    Solution:
    • The attribute MIDlet-Jar-URL is missing in the .jad file.


    Error message:
    Error installing suite (20): JAR not found: null

    Solution:
    • The url in attribute MIDlet-Jar-URL is not correctly set in the .jad file or the jar file is missing.


    Error message:
    Error installing suite (21): A required attribute is missing.

    Solution:
    • The attribute MIDlet-Jar-Size is missing in the .jad file.


    Error message:
    Error installing suite (25): A required suite ID attribute in the JAR manifest do not match the one in the JAD

    Solution:
    • The midlet name is not the same in attribute MIDlet-Name in the .jad file and in the MANIFEST.MF file inside the .jar file. Or this attribute is missing all together.


    Error message:
    Error installing suite (26): A required suite ID attribute in the JAR manifest do not match the one in the JAD

    Solution:
    • The version number is not the same in attribute MIDlet-Version in the .jad file and in the MANIFEST.MF file inside the .jar file. Or this attribute is missing all together.


    Error message:
    Error installing suite (27): A required suite ID attribute in the JAR manifest do not match the one in the JAD

    Solution:
    • The vendor name is not the same in attribute MIDlet-Vendor in the .jad file and in the MANIFEST.MF file inside the .jar file. Or this attribute is missing all together.


    Error message:
    Error installing suite (31): The Jar downloaded was not the size in the JAD

    Solution:
    • In the .jad file the wrong .jar file size is entered in attribute MIDlet-Jar-Size.
      The jar file size must be entered in bytes.


    Error message:
    Error installing suite (36): Corrupt JAR, error while reading: MobileStatu.class

    Solution:
    • In the .jad file the wrong class name is entered in attribute MIDlet-n


    Error message:
    Error installing suite (36): Corrupt JAR, error while reading: META-INF/MANIFEST.MF

    Solution:
    • In the .jar file the META-INF/MANIFEST.MF file is missing.


    Error message:
    Error installing suite (38): JAR did not have the correct media type, it had text/plain.

    Solution:
    • The mime types .jad and .jar are not correctly set in the webserver:

      text/vnd.sun.j2me.app-descriptor .jad
      application/java-archive .jar


    • More information of how to set the mime types in a Apache webserver, see quick guide: "mime.types file".


    Error message:
    Error installing suite (39): The JAD matches a version of a suite already installed.

    Solution:
    • cd C:\Tools\WTK22\appdb\DefaultColorPhone
    • Delete the #Sun%0020#Microsystems_#XXXXXX_suite.XXX files and the suite.utf file.


    Error message:
    Error installing suite (41): A required attribute is missing

    Solution:
    • The attribute MicroEdition-Configuration is missing in the MANIFEST.MF file inside the .jar file.


    Error message:
    Error installing suite (42): A required attribute is missing

    Solution:
    • The attribute MicroEdition-Profile is missing in the MANIFEST.MF file inside the .jar file.