Hewlett-packard user guide printer printer (333 pages)
Summary of Contents for Sun Microsystems J2ME
Page 1
User’s Guide J2ME Wireless Toolkit Sun Microsystems, Inc. 4150 Network Circle Santa Clara, California 95054 U.S.A. 1-800-555-9SUN or 1-650-960-1300 October 2004...
Page 2
Cette distribution peut comprendre des composants développés par des tierces parties. Sun, Sun Microsystems, le logoSun, Java, J2ME et le logo Java Coffee Cup sont des marques de fabrique ou des marques déposées de Sun Microsystems, Inc. aux Etats-Unis et dans d'autres pays.Le logo Adobe. et le logo PostScript sont des marques de fabrique ou des marques déposées de Adobe Systems, Incorporated.
Contents Preface ix 1. Introduction 1 1.1 Quick Start 1 1.2 The Tools in the Toolkit 2 1.3 Toolkit Features 3 1.4 Supported Technology 3 2. Developing MIDlet Suites 5 2.1 About Projects 5 2.2 The Simple Development Cycle 7 2.2.1 Edit Source Code 7 2.2.2 Build 8 2.2.3 Run 9...
Page 4
5.1.2 Execution Time and Number of Calls 41 5.1.3 Saving and Loading Profiler Information 41 5.2 Using the Memory Monitor 42 5.2.1 Saving and Loading Memory Monitor Information 44 5.3 Using the Network Monitor 44 J2ME Wireless Toolkit User’s Guide • October 2004...
Page 5
5.3.1 Filtering Messages 45 5.3.2 Sorting Messages 46 5.3.3 Saving and Loading Network Monitor Information 46 5.3.4 Clearing the Message Tree 47 6. Security and MIDlet Signing 49 6.1 Permissions 49 6.2 Protection Domains 50 6.3 Signing a MIDlet Suite 51 6.4 Managing Keys 52 6.4.1 Creating a New Key Pair 52 6.4.2 Getting Real Keys 53...
Preface This document describes how to work with the J2ME Wireless Toolkit. Who Should Use This Book This guide is intended for developers creating Mobile Information Device Profile (MIDP) applications with the J2ME Wireless Toolkit. You should already understand how to use, the Mobile Information Device Profile (MIDP), and the...
Mobile 3D Graphics - JSR 184 How This Book Is Organized This guide contains the following chapters and appendixes: Chapter 1 introduces the J2ME Wireless Toolkit and the development features it provides. Chapter 2 describes the development processes for creating and running MIDlets.
Page 11
Appendix A describes the application demonstrations that are included in the J2ME Wireless Toolkit. Appendix B explains how to use the functionality of the J2ME Wireless Toolkit from the command line. Appendix C describes internationalization features in the J2ME Wireless Toolkit.
We Welcome Your Comments We are interested in improving our documentation and welcome your comments and suggestions. You can email your comments to us at: wtk-comments@sun.com J2ME Wireless Toolkit User’s Guide • October 2004 Meaning The names of commands, files, and directories; on-screen...
Introduction This book describes how to use the J2ME Wireless Toolkit. The J2ME Wireless Toolkit is a set of tools that makes it possible to create applications for mobile phones and other wireless devices. Although it is based on the Mobile Information Device Profile (MIDP) 2.0, the J2ME Wireless Toolkit also supports a handful of optional packages, making it a widely capable development toolkit.
{toolkit}\apps\games\src directory. The Tools in the Toolkit The J2ME Wireless Toolkit has three main components: KToolbar automates many of the tasks involved in creating MIDP applications. The emulator is a simulated mobile phone. It is useful for testing MIDP applications.
The only additional tool you need is a text editor for editing source code. Toolkit Features The J2ME Wireless Toolkit supports the creation of MIDP applications with the following main features: Building and packaging: You write the source code and the toolkit takes care of the rest.
Page 16
Supported JCP APIs in the J2ME Wireless Toolkit TABLE 1 JSR 135 MMAPI 1.1 JSR 75 PIM and File JSR 82 Bluetooth and OBEX JSR 172 JSR 184 3D Graphics J2ME Wireless Toolkit User’s Guide • October 2004 Name Mobile Media API http://jcp.org/en/jsr/detail?id=135...
MIDlet suite, including Java source files, resource files, and the MIDlet descriptor. The J2ME Wireless Toolkit works on one project at a time. You can create a new project or open an existing project.
Page 18
The default options are fine for this example; just click on OK to dismiss the window. In the KToolbar console, you’ll see some messages telling you exactly where to store the source code and resource files for this project. J2ME Wireless Toolkit User’s Guide • October 2004...
2.2.1 Edit Source Code Editing source code is the only step in which the J2ME Wireless Toolkit is no help at all. You will need to use the text editor of your choice to create and edit source code files.
KToolbar console. If you have errors, go back and edit the source code to fix them. Once you’ve eliminated your errors, the KToolbar console tells you the project was successfully built. J2ME Wireless Toolkit User’s Guide • October 2004...
Messages about building FIGURE 5 Behind the scenes, the J2ME Wireless Toolkit also preverifies the compiled class files. MIDlet class files must be preverified before they can be run on a MIDP device or emulator. The toolkit quietly handles this detail for you; you probably won’t ever realize it’s happening.
Page 22
List of project MIDlets FIGURE 6 Choose the MIDlet you want and select Launch. If you’re following along with the TinyMIDlet example, you’ll see the fruit of your labors: TinyMIDlet in action FIGURE 7 J2ME Wireless Toolkit User’s Guide • October 2004...
2.3.1 Package The J2ME Wireless Toolkit automates the task of packaging a MIDlet suite. The end result of packaging is two files, a MIDlet descriptor and a MIDlet suite JAR. The descriptor is a small text file that contains information about the MIDlet suite. The JAR contains the class files and resources that make up the MIDlet suite.
The emulator also has the capability of installing applications into its memory in a process that resembles how applications are transmitted and installed on real devices. To install applications in the J2ME Wireless Toolkit emulator, choose Project > Run via OTA.
Page 25
URL prompt FIGURE 9 Choose Go from the menu to begin the installation. The emulator shows a list of the applications it finds at the URL. Choose the only one and select Install from the menu. The emulator gives you one last chance to confirm your intentions. Confirming the installation FIGURE 10 Choose Install again to finish the installation.
OTA, it allows you to see how your application performs on the device. 2.3.3 Once the application is installed, running it is simple. Just choose the application from the list and choose Launch from the menu. J2ME Wireless Toolkit User’s Guide • October 2004...
You can use an obfuscator in the packaging step of the development cycle. Although the J2ME Wireless Toolkit doesn’t come with an obfuscator, it is already configured to use the ProGuard obfuscator. All you need to do is download ProGuard and put it in a place where the toolkit can find it.
Page 28
Replace “scriptfile” with the name you used for the script file. You will need to quit and restart KToolbar for the change to take effect. The J2ME Wireless Toolkit also includes support for RetroGuard. If you want to use RetroGuard, you’ll need to download it separately and change the toolkit’s configuration.
The MIDP 2.0 specification includes the Over The Air User Initiated Provisioning Specification, which describes how MIDlet suites can be transferred over-the-air (OTA) to a device. You can test this type of scenario using the J2ME Wireless Toolkit emulator. To deploy a packaged MIDP application remotely on a Web server: 1.
Page 30
AMS. (You may already be familiar with the AMS if you have used KToolbar’s Run via OTA option. To launch the emulator’s AMS, you have two options: In the Windows start menu, choose Start > Programs > J2ME Wireless Toolkit 2.2 > OTA Provisioning. From the command line, run: {toolkit}\bin\emulator -Xjam Now follow the AMS prompts to install your application.
C H A P T E R Working With Projects In the last chapter, you learned how the J2ME Wireless Toolkit helps you with the MIDP development cycle. This chapter delves more deeply into the details of working with projects, including the following:...
Page 32
APIs. The API selections you make in the project settings apply only to building a project. In essence, the API selections choose which classpath the toolkit uses for compiling and preverifying your source files. J2ME Wireless Toolkit User’s Guide • October 2004...
Consult the MIDP 2.0 specification for the definitions of the required and optional attributes. The J2ME Wireless Toolkit takes care of most of the details. In the early stages of development, you might not have to worry about the attributes at all.
Page 34
You can then edit the attribute value by clicking in the value column next to the key, just as you would with required or optional attributes. Select an attribute and click on Remove if you wish to remove the key and value entirely. J2ME Wireless Toolkit User’s Guide • October 2004...
Manipulating MIDlets The project settings also provide a way to add or modify the MIDlets that are contained in the current MIDlet suite project. To see how this works, start KToolbar and open an existing project. Click on Settings... and choose the MIDlets tab. You will see a list of all MIDlets in the project.
To add an entry to the push registry, press Add and fill in values for the connection URL, MIDlet class, and allowed sender. To edit an entry, select the entry and press the Edit button. To remove a push registry entry, select it and press Remove. J2ME Wireless Toolkit User’s Guide • October 2004...
Project > Clean from the KToolbar menu. Using Third-Party Libraries The J2ME Wireless Toolkit allows you to incorporate third-party libraries in your applications. Using third-party libraries can cut down on your development time by providing functionality you don’t wish to build yourself, but you should keep a close eye on the size of your MIDlet suite JAR.
Libraries should be JAR or Zip files of Java classes. For example, if you installed the J2ME Wireless Toolkit in C:\WTK22 and your application is called Tiny, the class library would go in C:\WTK22\apps\Tiny\lib. When you build, run, debug, and package your project, the class files in the lib directory are used.
3.7.1 Setting the Application Directory By default, the J2ME Wireless Toolkit stores applications in directories under {toolkit}\apps. You can change this by adding a line to ktools.properties of the following form: kvem.apps.dir: Any backslash ('\') characters in the directory’s path should be preceded by another backslash.
Page 40
J2ME Wireless Toolkit User’s Guide • October 2004...
C H A P T E R Using the Emulator The J2ME Wireless Toolkit emulator simulates a MIDP device on your desktop computer. It is a convenient way to see how your application performs in a MIDP environment and gives you a tight development cycle that is entirely contained on your desktop computer.
The emulator looks and acts like a mobile phone. In this section you’ll learn how to control the emulator. Although the description and figures are based on the DefaultColorPhone skin, all the skins operate in a similar way. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 43
The DefaultColorPhone emulator skin FIGURE 17 Chapter 4 Using the Emulator...
Configuration tab, fill in the names and port numbers for the proxy server you wish to use. You can also select which version of HTTP you wish to use. J2ME Wireless Toolkit User’s Guide • October 2004 Keyboard key Enter...
Note – If multiple instances of the same emulator skin run simultaneously, the J2ME Wireless Toolkit will generate unique file paths for each one. For example, a second instance of DefaultColorPhone might have a file path name of {toolkit}\appdb\DefaultColorPhone.1089982856218.
MIDP device usually has a slower processor, less memory, and a slower network connection, and might have a different type of display. The J2ME Wireless Toolkit allows you to simulate the constrained environment of a real device. Although the emulator does not represent a real device, adjusting the performance settings gives you useful information about how your application performs under varying runtime conditions.
Adjusting the emulator’s performance FIGURE 19 Adjust the Graphics primitives latency to have an effect on the amount of time that elapses between your application’s calls to drawing methods in the Graphics class and when the drawing actually takes place. To change the screen characteristics, choose one of the Display refresh types.
Run button or using the Project > Run via OTA feature. For testing or demonstrations, you might wish to run the emulator by itself. Several different approaches are described in this section. The program group created by the J2ME Wireless Toolkit installer includes several items that pertain to running the emulator by itself.
Page 49
is usually to unpack or install the third party emulator, then copy its directory into the <toolkit>/wtklib/devices directory. Next time you run KToolbar, the emulator is available. A partial listing of some of the currently available emulators is available here: http://developers.sun.com/techtopics/mobility/midp/articles/ emulators/ Chapter 4...
Page 50
J2ME Wireless Toolkit User’s Guide • October 2004...
C H A P T E R Monitoring Applications The J2ME Wireless Toolkit provides several tools to monitor the behavior of your applications. These tools are helpful in debugging and optimizing your code. The profiler lists the frequency of use and execution time for every method in your application.
Page 52
The profiler pops up with information about all the method calls in your application. The method profiler FIGURE 21 The profiler displays two types of information: Method relationships are shown in a hierarchical list, the Call Graph. J2ME Wireless Toolkit User’s Guide • October 2004...
The right side of the profiler shows the execution time and number of calls for each method and its descendants. Note – The profiling values obtained from the emulator do not reflect actual values on a real device. 5.1.1 The Call Graph The call graph shows a hierarchy of method calls.
Using the Memory Monitor Memory is scarce on many MIDP devices. The J2ME Wireless Toolkit includes a memory monitor that makes it easy to examine the memory usage of your application. You can see the total memory used by your application and a detailed listing of the memory usage per object.
Page 55
Maximum. The maximum amount of memory used since program execution began, shown in the graph by a broken red line. Objects. The number of objects in the heap. Used. The amount of memory used. Free. The amount of unused memory available. Total.
To turn on the network monitor, choose Edit > Preferences... from the KToolbar menu. Click on the Monitor tab. Check Enable Network Monitoring. Next time you run the emulator, the network monitor window pops up. J2ME Wireless Toolkit User’s Guide • October 2004...
The network monitor FIGURE 24 When your application makes any type of network connection, information about the connection is captured and displayed. The figure shows two HTTP requests and responses. The display on the left side shows a hierarchy of messages and message pieces. Click on a message or a portion of a message to see details in the right side of the network monitor.
To save your network monitor session, choose File > Save or File > Save As... from the network monitor window menu. Choose a file name. J2ME Wireless Toolkit User’s Guide • October 2004 Filter Settings Enter text to match the various parts of HTTP messages: URL, status line, headers, or body.
To load a network monitor session, choose File > Utilities... from the KToolbar menu. Click on Open Session in the Network Monitor box. When you select a file, the network monitor window appears with all the session information. 5.3.4 Clearing the Message Tree To remove all messages from the network monitor, choose Edit >...
Page 60
J2ME Wireless Toolkit User’s Guide • October 2004...
MIDlet suites. For definitive information, consult the MIDP 2.0 specification. For an overview of MIDlet signing using the J2ME Wireless Toolkit, read this article: Understanding MIDP 2.0's Security Architecture http://developers.sun.com/techtopics/mobility/midp/articles/...
In the J2ME Wireless Toolkit, you can add these permission attributes to a project by clicking on the Settings... button in KToolbar. Select the Permissions tab. The MIDlet-Permissions box shows permissions which the MIDlet must possess, while the MIDlet-Permissions-Opt box contains permissions that the MIDlet would like to have but does not need absolutley.
MIDlet suite. Assuming everything checks out, the device or emulator installs the MIDlet suite into whatever protection domain is associated with Super-Trustee’s root certificate. The J2ME Wireless Toolkit provides tools to sign MIDlet suites, manage keys, and manage root certificates. Signing a MIDlet Suite To sign a MIDlet suite, you must package it first.
Creating a New Key Pair To create an entirely new key pair, click on New Key Pair... The toolkit prompts you for a key alias and information that will be associated with the key pair. J2ME Wireless Toolkit User’s Guide • October 2004...
6.4.2 Getting Real Keys The ability to create a key pair and sign a MIDlet within the J2ME Wireless Toolkit environment is for testing purposes only. When you run your application on an actual device, you must obtain a signing key pair from a certificate authority recognized by the device.
The procedure for signing MIDlet suites with real keys works like this: 1. Generate a new key pair. In the J2ME Wireless Toolkit you can do this by pressing New Key Pair... in the MIDlet signing window, as described above.
Real devices have similar lists of root certificates, although they cannot usually be modified by the user. When you want to deploy your application on a real device, you’ll have to use signing keys issued by a certificate authority whose root certificate is present on the device.
6.5.2 Removing Certificates To remove a certificate from the list, select the certificate and choose Action > Delete Selection. J2ME Wireless Toolkit User’s Guide • October 2004...
C H A P T E R Using the Wireless Messaging API The J2ME Wireless Toolkit supports the Wireless Messaging API (WMA) with a sophisticated simulation environment. WMA 1.1 (JSR 120) enables MIDlets to send and receive Short Message Service (SMS) or Cell Broadcast Service (CBS) messages.
You can simulate some of the hazards of the wireless network in the J2ME Wireless Toolkit. As before, choose Edit > Preferences... from the KToolbar menu and click on the WMA tab.
Sending Messages With the WMA Console The WMA console is a handy utility that allows you to send and receive messages. You can, for example, use the WMA console to send SMS messages to a MIDlet running on the emulator. To launch the WMA console, choose File >...
You can use the WMA console to send the contents of a file as a binary message. Click on Send SMS... to bring up the send window. Click on the Binary SMS tab. J2ME Wireless Toolkit User’s Guide • October 2004...
Sending a binary message FIGURE 32 Selecting recipients is the same as for sending text SMS messages. You can type in the path of a file directly, or click on Browse... to open up a file chooser. 7.3.3 Sending Text or Binary CBS Messages Sending CBS messages is similar to sending SMS messages except that you don’t need to choose recipients.
Add button. For example, to send a message to a running emulator whose number is +5550001, you would fill in the To line as mms:// +5550001. To remove a recipient, first select its line, then click on Remove. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 75
Adding recipients for an MMS message FIGURE 34 To add media files to the message, click on the Parts tab. Click on Add to add a part to the message. To remove a part, select it and press Remove. Adding parts to an MMS message FIGURE 35 Chapter 7 Using the Wireless Messaging API...
Click on a message or message fragment to see its details in the right pane. Using the network monitor to view a WMA message FIGURE 36 J2ME Wireless Toolkit User’s Guide • October 2004 Chapter 5, “Monitoring Applications.”...
C H A P T E R Using the Mobile Media API The Mobile Media API (MMAPI) provides a standard API for rendering and capturing time-based media, like audio or video. The API was designed to be flexible with respect to the media formats, protocols, and features supported by various devices.
MIDlet is paused. The J2ME Wireless Toolkit will print a message to the console if you pause a MIDlet and it does not stop its running Players. You can test this feature yourself using the PausingVideoTest MIDlet in the mmademo demonstration application.
This chapter provides a brief overview of working with 3D graphics content. JSR 184 Overview JSR 184 is a specification that defines the Mobile 3D Graphics (M3G) API for J2ME. This API provides 3D functionality in a compact package that’s appropriate for CLDC/MIDP devices.
In general, however, the best way to improve the rendering speed of 3D scenes is to make some compromises in quality. The Mobile 3D Graphics API includes rendering hints so that applications can suggest how the implementation can compromise quality to improve rendering speed. J2ME Wireless Toolkit User’s Guide • October 2004...
Creating Mobile 3D Graphics Content Most mobile 3D applications will use scene graphs in resource files to describe objects, scenes, and characters. Usually it is not programmers but graphic designers or artists who create the scene graphs, using standard 3D modeling tools. Several vendors offer tools for authoring content and converting files to the JSR 184 format.
Page 82
J2ME Wireless Toolkit User’s Guide • October 2004...
{toolkit}\appdb\DefaultColorPhone\filesystem\root1\Readme. Note – If multiple instances of the same emulator skin run simultaneously, the J2ME Wireless Toolkit will generate unique file paths for each one. For example, a second instance of DefaultColorPhone might have a file system path name of...
Each subdirectory of filesystem is called a root. The J2ME Wireless Toolkit provides a mechanism for managing roots. While the emualtor is running, choose MIDlet > External events from the emulator window’s menu. You’ll see a utility window for adding and removing roots.
C H A P T E R Using the Bluetooth and OBEX APIs The J2ME Wireless Toolkit emulator supports JSR 82, the Java APIs for Bluetooth. JSR 82 includes two independent APIs: The Bluetooth API provides an interface to Bluetooth wireless networking, including device discovery and data exchange.
11.3 Setting OBEX and Bluetooth Preferences The J2ME Wireless Toolkit allows you to configure the Bluetooth and OBEX simulation environment. Choose Edit > Preferences... from the KToolbar menu to see the following window. Bluetooth and OBEX preferences FIGURE 38 11.3.1 OBEX Preferences Devices using IrDA in the real world discover other devices by “listening”.
Bluetooth BCC Properties The Bluetooth Control Center (BCC) controls Bluetooth settings. Some devices may provide a GUI to customize Bluetooth settings. In the J2ME Wireless Toolkit, the BCC is configured using the BCC Properties tab of the Bluetooth preferences. The...
Page 88
J2ME Wireless Toolkit User’s Guide • October 2004...
C H A P T E R Using Web Services The J2ME Wireless Toolkit emulator supports JSR 172, the J2ME Web Services Specification. JSR 172 provides APIs for accessing web services from J2ME applications. It also includes an API for parsing XML documents.
Page 90
J2ME Wireless Toolkit User’s Guide • October 2004...
This appendix describes the application demonstrations that are bundled with the J2ME Wireless Toolkit. Overview The J2ME Wireless Toolkit includes demonstration applications that highlight some of the technologies and APIs that are supported by the emulator. The following table lists all the demonstration applications that are included in this release.
Page 92
BluetoothDe Demo3D Demos FPDemo Games JSR172Demo mmademo NetworkDem ObexDemo PDAPDemo J2ME Wireless Toolkit User’s Guide • October 2004 APIs Description MMAPI 1.1 Demonstrates audio capabilities, including mixing and playing audio with an animation JSR 82 Demonstrates device discovery Bluetooth and data exchange using...
The first step is to run KToolbar. To do this, go to the Windows Start menu and choose Start > Programs > J2ME Wireless Toolkit 2.2 > KToolbar. The KToolbar window pops up:...
Bluetooth network. To make images available, select them and choose Publish image from the menu. Images with a green icon are published, while those with a purple icon are not. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 95
Running the Bluetooth Demo server FIGURE 42 On the second emulator, choose Bluetooth Demo, then Client. The MIDlet tells you it’s ready to search for images. Choose Find. The MIDlet will find the other emulator and get a list of images from it. Select one from the list and choose Load. The emulator asks if you want to allow the connection.
5 neighbors die of overcrowding. An empty cell with exactly 4 neighbors will become a new live cell. The view of the playing board rotates slowly so you can view the board from all angles. J2ME Wireless Toolkit User’s Guide • October 2004...
The Game of Life in three dimensions FIGURE 44 The keypad buttons provide control over the game. Controls for Life3D TABLE 9 Button This source code for this example is particularly well-documented. Take a look at {toolkit}\apps\Demo3D\src\com\superscape\m3g\wtksamples\life3d\Lif e3D.java. A.4.2 PogoRoo PogoRoo shows you the rear end of a kangaroo bouncing up and down on a pogo stick.
You might need to hold down the keys to see an effect. A.4.3 retainedmode The retainedmode MIDlet plays back a scene file that shows a tireless skateboarder in an endless loop. J2ME Wireless Toolkit User’s Guide • October 2004...
To see what’s going on behind the scenes, use the network monitor. mmademo The mmademo application contains four MIDlets that showcase the multimedia capabilities of the J2ME Wireless Toolkit. This section describes the MIDlets and includes additional information about using multimedia from your applications. Appendix A...
Audio Capture from a default device lets you capture audio from the microphone or connected device. The sound is captured and played back on the speaker. To avoid feedback, use a headset. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 101
Video Capture Simulation simulates viewing input video such as might be possible on a device equipped with a camera. [enter URL] allows you to play back media files from arbitrary HTTP servers. Type a valid URL at the insertion point and click OK to play a file. If you want to open an HTTP directory from which to select media, be sure to add a slash to the end of the URL.
A.6.3 PausingAudioTest This MIDlet exists to demonstrate how the J2ME Wireless Toolkit will warn you if a paused MIDlet has not stopped its running Players. After you launch the MIDlet, choose the Play command to start playing some audio. The screen displays a status, which is either “Well-behaved”...
Animated GIFs and video capture can be implemented using either a Form Item or a Canvas. The Video demonstration includes all the possibilities: Animated GIF - Form [jar] shows an animated GIF as a Form Item. The form also includes some information about the playback, including the current time.
Page 104
Select one and choose Send. The emulator will ask for permission to make the outgoing connection. Choose Yes. Back in the first (listening) emulator, you’ll see a prompt asking whether you want to accept the incoming connection. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 105
Prompting to accept a connection FIGURE 48 Choose Yes. The image you selected is transferred over the simulated infrared link and displayed on the first emulator. A successfully transferred image FIGURE 49 Appendix A Application Demonstrations...
You can browse through the available directories and files. By default there is one directory, root1. Browsing files FIGURE 50 Select a directory and press the select button to enter it. The root1 directory contains a single file, Readme. J2ME Wireless Toolkit User’s Guide • October 2004...
Page 107
Contents of the root1 directory FIGURE 51 Using the commands in the demonstration, you can view the file or see its properties. Try selecting the file and choosing Properties or View from the menu. Viewing file properties and contents FIGURE 52 Appendix A Application Demonstrations...
Once you've selected a list type and chosen the specific list, you'll see all the items in the list. If this is the first time you've run the example, the list is probably empty. J2ME Wireless Toolkit User’s Guide • October 2004 Chapter 10...
Page 109
An empty contact list FIGURE 54 To add an item, choose New from the menu. The application prompts you for a Formatted Name for the item. You can add more data fields to this item using Add Field in the menu. You'll see a list of field names. Pick one, then enter the value for the new field.
WMADemo This application shows how to send and receive SMS, CBS, and MMS messages. The J2ME Wireless Toolkit offers a flexible emulation environment to support messaging. Messages can be exchanged between emulator instances and can be generated or received using the WMA console utility.
Page 111
To see the magic of the push registry, use the WMA console to send the emulator a message. Launch the console by choosing File > Utilities... from the KToolbar menu. Click on the Open Console button in the WMA box to launch the WMA console.
Page 112
SMS message. An incoming text message FIGURE 59 You can also use the WMA console to send and receive CBS and MMS messages. Chapter 7, “Using the Wireless Messaging J2ME Wireless Toolkit User’s Guide • October 2004 API,” for more information.
Page 113
If you are attempting to send text messages to WMADemo using the WMA console, make sure to specify the port number as 50000. Use port 50001 for CBS messages. For MMS messages, use example.mms.MMSDemo as the application ID. For example, to send an MMS message from the WMA console to the emulator, make sure that WMADemo has been installed using Run via OTA as described above.
Page 114
FIGURE 61 Click on Send to send the message. The emulator asks if it can launch WMADemo. Click on Yes. The image and its information are displayed. WMADemo receives the image FIGURE 62 J2ME Wireless Toolkit User’s Guide • October 2004...
You can find these files under the {toolkit}\apps\<demo>\bin directory where {toolkit} is the installation directory of the J2ME Wireless Toolkit and <demo> is the name of one of the demo applications. The Development Cycle For a full description of developing MIDP applications, see MIDlet Suites.”...
JAR files to the -bootclasspath option. For more information on javac, consult the J2SE documentation. The next step is to preverify the class files. In the bin directory of the J2ME Wireless Toolkit lives a handy utility called preverify. The syntax for the...
As a result of this command, preverified class files are placed in the classes directory. If your application uses WMA, MMAPI, or other versions of CLDC or MIDP, be sure to include the relevant .jar files in the classpath. B.2.2 Package To package a MIDlet suite, you must create a manifest file, an application JAR, and finally, a MIDlet suite descriptor.
MIDlet-Vendor: My Organization MIDlet-Version: 1.0 MIDlet-Jar-URL: MyApp.jar MIDlet-Jar-Size: 24601 B.2.3 You can run the emulator from the command line. The J2ME Wireless Toolkit’s bin directory contains the command emulator. The syntax for the emulator command is as follows: options emulator [ The general options are: -help: Display a list of valid options.
remove=[<storage_name> | <storage_number> | all] Remove a previously installed application. The application is specified by its valid storage name or storage number. Specifying all, all previously installed applications are removed. transient=<jad_file_url> Install, run, and remove the application with the specified JAD file. Specifying transient causes the application to be installed and run and then removed three times.
Launching Toolkit GUI Components The components of the J2ME Wireless Toolkit can all be launched from the command line. Each component is in the toolkit’s bin directory. Toolkit component commands TABLE 12 Command DefaultDevice ktoolbar prefs utils Setting Emulator Preferences You can change the emulator preferences from the command line by using the - Xprefs option for the emulator command.
Using Security Features The full spectrum of the J2ME Wireless Toolkit’s security features are also available from the command line. You can adjust the emulator’s default protection domain, sign MIDlet suites, and manage certificates. B.5.1 Changing the Emulator’s Default Protection Domain To adjust the emulator’s default protection domain, use the following option with...
B.5.2 Signing MIDlet Suites JadTool is a command-line interface for signing MIDlet suites using public key cryptography according to the MIDP 2.0 specification. Signing a MIDlet suite is the process of adding the signer certificates and the digital signature of the JAR file to a JAD file.
Delete a key from the given ME keystore with the given owner. The ME keystore is {toolkit}\appdb\_main.ks. Note – The J2ME Wireless Toolkit contains an ME keystore called _main.ks, which is located in the appdb subdirectory. This keystore includes all the certificates that exist in the default J2SE keystore, which comes with the J2SE SDK installation.
Using the Stub Generator J2ME Clients can use the Stub Generator to access web services. The wscompile tool generates stubs, ties, serializers, and WSDL files used in JAX-RPC clients and services. The tool reads a configuration file, which specifies either a WSDL file, a model file, or a compiled service endpoint interface.
B.6.1.1 Example wscompile -gen -d generated config.xml wscompile -gen -f:nounwrap -O -cldc1.1 -d generated config.xml J2ME Wireless Toolkit User’s Guide • October 2004 Description turn on explicit service context mapping turn off data binding for literal encoding turn off encoding type information...
A P P E N D I X Internationalization This appendix describes setting the language displayed in the J2ME Wireless Toolkit and the localization setting of the emulation environment. Locale Setting A locale is a geographic or political region or community that shares the same language, customs, or cultural conventions.
Emulated Locale The microedition.locale property is the MIDP system property that defines the current locale of the device, which is null by default. For the J2ME Wireless Toolkit emulator, this value is automatically set to the default locale for the J2SE environment you are running.
Note – All the J2SE encoders are available in the emulated environment. See the J2ME Wireless Toolkit Basic Customization Guide for information on how to limit the list of available encoders for a specific device. C.3.1 Java Compiler Encoding Setting The javac.encoding property determines the encoding used by the javac...
Page 130
J2ME Wireless Toolkit User’s Guide • October 2004...
Need help?
Do you have a question about the J2ME and is the answer not in the manual?
Questions and answers