Home

Sun Microsystems J2ME User's Manual

image

Contents

1. FIGURE 12 Launching the installed application J Install Application Tiny 2 Info 3 Remove 4 Update 5 Application Settings 6 About Running an application on a real device depends heavily on the device itself Consult your device documentation for information Using an Obfuscator An obfuscator is a tool that reduces the size of class files MIDlet suites need to be compact both to minimize download times and to comply with sometimes stringent limits on JAR size imposed by manufacturers or carriers Using an obfuscator is one way not the only way that you can keep your MIDlet suite JAR small 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 ProGuard is published under the terms of the GNU General Public License GPL If you are comfortable with the terms of the license you can download and use ProGuard free of charge Installing ProGuard in the J2ME Wireless Toolkit is straightforward 1 Go to the ProGuard web site http proguard sourceforge net 2 Download the latest version Chapter 2 Developing MIDlet Suites 15 2 4 3 Uncompress the proguard jar file from the lib directory of the ProGuard installation to the bin directory of your J2ME Wireless
2. jJavac encoding EUCJIS C 4 Font Support in the Default Emulator The default fonts that are used in the emulated environment are set according to the underlying window system locale By default the MIDP environment fonts are mapped to the default J2SE environment Java fonts These fonts usually support all the characters that are required by the current window s locale You can override these fonts to support other characters that are not supported by the default fonts See the J2ME Wireless Toolkit Basic Customization Guide for information on how to configure them Appendix 6 Internationalization 7 118 J2ME Wireless Toolkit User s Guide October 4 development cycle full 11 simple 7 E emulator 29 keyboard shortcuts 32 performance 34 preferences 32 running solo 36 skins 29 emulator command 106 emulators default font support 117 language support 115 encoding javac 27 F FileConnection API 71 managing roots 72 font support 117 G generating stub from command line 113 H heap size 33 help option 106 I import command 112 119 Index A advanced configuration options 26 application descriptor 11 Application Management Software AMS 12 applications running remotely 17 applications directory setting 27 attributes 21 B building source code 8 C call graph 41 CBS message sending 61 certificate importing 55 certificate management 54 certificat
3. 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 PogoRoo PogoRoo shows you the rear end of a kangaroo bouncing up and down on a pogo stick Appendix A Application Demonstrations 85 A 4 2 FIGURE 45 A bouncing kangaroo You can get the kangaroo to bounce around the landscape by using the arrow keys Push up to go forward down to go backward and left and right to change direction 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 86 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 46 A tireless skateboarder JSR172Demo JSR172Demo shows how to access a web service from a MIDlet The web service is already running on an Internet server You should be able to simply build and run the example If you are behind a firewall you ll need to configure the emulator s proxy server settings Choose Edit gt Preferences from the KToolbar menu then select the Network Preferences tab Fill in the proxy server addresses and ports JSR172Demo contains a single MIDlet Server Script Launch it and follow the prompts You can browse through simulated news headlines all of which are retrieved from the web service To see what s going on behind the scenes use the network
4. and choose the Push Registry tab FIGURE 16 Project push registry settings EHI Settings for project WMADemo x API Selection Required Optional User Defined MiDlets P Permissions Connection URL Allowed Sender isms SO000 lexample sms SMSRe chs 50001 lexample chs CBSRe mms ftexample mms example anms MMSR 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 24 J2ME Wireless Toolkit User s Guide October 2004 If you do make push registry entries for your application make sure you also enter the appropriate permissions See Chapter 6 Security and MIDlet Signing for details Project Directory Structure Projects have a standard directory structure The project itself is represented by a directory in toolkit apps For example the demos project is contained in toolkit apps demos Inside a project directory the following directories are used TABLE 2 Project directory structure Directory Description bin The MIDlet suite descriptor and JAR are placed in this directory when you package the project This directory also contains the unpackaged manifest information and might include an HTML file that is used internally when you do Run via OTA classes This directory is used
5. Appendix A Application Demonstrations 3 FIGURE 43 An image transferred via simulated Bluetooth You can avoid the permission prompts by running the demonstration in the trusted protection domain Demo3D This application contains three MIDlets that show off the emulator s support of JSR 184 the Mobile 3D Graphics API Life3D Life3D implements the popular Game of Life in three dimensions Live cells are represented by cubes Each cell has 26 possible neighbors including diagonals For each step of the animation cells with fewer than 4 neighbors die of loneliness while cells with more than 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 A 4 A 4 1 84 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 44 The Game of Life in three dimensions The keypad buttons provide control over the game TABLE 9 Controls for Life3D Button Description 0 Pause the animation Resume the animation at its default speed Speed up the animation Slow down the animation Ae WO N e Choose the previous preset configuration from a list that includes gems like P4 Glider Skew beehive plus and P4 Rotor 5 Choose the next preset configuration from the list Generate a random configuration and animate until it stabilizes or dies If it dies generate a new random configuration
6. B 5 2 Managing Certificates MEKeyTool manages the public keys of certificate authorities CAs making it functionally similar to the keytool utility that comes with the J2SE SDK The keys can be used to facilitate secure HTTP communication over SSL HTTPS Before using MEKeyTool you must first have access to a Java Cryptography Extension JCE keystore You can create one using the 255 keytool utility see http java sun com j2se 1 4 docs tooldocs win32 keytool html for more information To run MEKeyTool open a command prompt change the current directory to toolkit bin and enter the following command mekeytool exe lt command gt The commands are as follows help Print the usage instructions for MEKeyTool import alias lt alias gt keystore lt JCEkeystore gt storepass lt storepass gt domain lt domain_name gt Import a public key into the ME keystore from the given JCE keystore using the given JCE keystore password The default ME keystore is toolkit appdb _main ks and the default JCE keystore is user home keystore is List the keys in the ME keystore including the owner and validity period for each The ME keystore is toolkit appdb _main ks delet owner lt owner gt number lt key number gt 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 cal
7. Chapter 2 Developing MIDlet Suites 223 FIGURE6 List of project MIDlets 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 FIGURE7 TinyMID1let in action Welcome to the world of MiDlets 10 J2ME Wireless Toolkit User s Guide October 2004 The Full Development Cycle The second development cycle is slightly more complicated Edit source code Package Install gt Run 1 Edit source code This is the same as in the simple cycle 2 Package In this step the J2EME Wireless Toolkit compiles and preverifies the source files essentially the same as the Build step from before Then it bundles the Java class files and resource files into a MIDlet suite JAR file and a MIDlet suite descriptor 3 Install MIDlet suites need to be installed before they can be run You can install the MIDlet suite into the J2ME Wireless Toolkit emulator or a real device 4 Run As in the simple development cycle run your application and test for bugs In the full development cycle the first step is identical to the simple development cycle Editing source code is the same as always The Build step is now incorporated in packaging The full development cycle includes two new steps packaging and installing Finally running an installed application is different in important ways from running an application in the simple development cycle P
8. Formatted Hame Jonathan Knudsen To actually save the list item choose Commit from the menu Appendix A Application Demonstrations 7 FIGURE 56 Saving an item E Mail jonathan kKnudsen sun co Formatted Hame Jonathan Knudsen Menu 4 Add Field 2 Show vCard 3 fos 4 Remove Field You can return to the list by choosing the Back command You ll see the item you just created in the list The items that you create are stored in standard vCard or vCalendar format in the toolkit appdb skin pim directory See Chapter 10 for more information The PIM API allows for exporting contact calender and to do items in a standard format The exact format depends on the list type When you are viewing an item in any list the menu contains a command for viewing the exported item For example when you are viewing a contact list item the menu contains Show vCard When you choose this command the exported item is shown on the screen Calendar items and to do items both get exported as vCalendar 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 Because this example makes use of the push registry you can t see all of its features just by using the Run button You need
9. The changes will take effect the next time the emulator is executed Now run your application by clicking on the Run button Interact with your application as you normally would When you re finished shut down the emulator The profiler pops up with information about all the method calls in your application FIGURE 21 The method profiler EE Methods Profiler 5550000 DefaultColorPhone Wireless Toolkit calls under lt root gt Count Cycles Cycles_ Cycles With cycles eroot gt 0 21027468 100 4 icom sun midp icdui DefaultEventHandler QueuedEventHandler run 77254 3 11323693 53 8 jutil Worker run 305 6 9097127 43 2 Icom sun midp icdui EmulEventHandler systemEvert 1 8505176 40 4 8505176 40 4 jutil Worker runTask 2 63 6 8287393 33 4 util Worker doRun 1 56550 02 8186714 38 9 1 23 com sun midp main imidp AbstractTest run 1 582 6 7481866 355 7 java lang StringBuffer toString 1 3654156 17 3 3654156 17 3 Imidp tests ConnectionTest run 1 877 6 3510394 16 6 midp tests PropertyTest run 1 533 6 2650552 12 6 java lang System getProperty 12 2636542 125 2636542 125 midp ProgressCanvas paint 89 40064 01 1529329 7 2 icom sun midp DefaultEventHandler repaintScreenEvent 83 10213 6 1513247 7A javax microedition Icdui Font getHeight 264 1435190 8 1435190 8 Imidp WringerMiDlet completed 2 3317 0 808744 38 midp ProgressCanvas ce
10. d lt output directory gt f lt features gt features lt features gt gen gen client httpproxy lt host gt lt p ort gt import model lt file gt 0 s lt directory gt verbose version 0 1 1 0 B 6 B 6 1 Note Exactly one gen option must be specified The f option requires a comma separated list of features TABLE 15 lists the features delimited by commas that can follow the option The wscompile tool reads a WSDL file compiled service endpoint interface SEI or model file as input The Type of File column indicates which of these files can be used with a particular feature Type of File WSDL WSDL WSDL SEI model WSDL SEI model WSDL WSDL WSDL SEI model Command Supported Features f for wscompile Description turn on explicit service context mapping turn off data binding for literal encoding turn off encoding type information turn off support for multiple references turn off full validation of imported WSDL documents search schema aggressively for subtypes turn on direct serialization of interface types enable WSI Basic Profile features default Resolve xsd IDREF No unwrap gen d generated config xml TABLE 15 Option explicitcontext nodatabinding noencodedtypes nomultirefs novalidation searchschema serializeinterface 9 wsi resolveidref nounwrap Example wscompil wscompile gen f nounwrap O
11. s Guide October 2004 FIGURE 17 The DefaultColorPhone emulator skin 2 5550000 DefauliColorPhone lt MIDlet Help power button PSSST eee estes sss ssssesssssssiiee x 2 r 4 4 4 44 4 4 4 4 444 44 444 soft buttons Chapter 4 Using the Emulator 1 You can use the mouse to click on the buttons to press them Most buttons also have keyboard shortcuts which are generally easier to use Keyboard numbers 0 through 9 correspond to the emulator s 0 through 9 buttons Some less obvious keyboard shortcuts are in the following table TABLE 4 Keyboard shortcuts Emulator button Keyboard key Left soft button F1 Right soft button F2 Power button Esc SELECT Enter Entering text works much as it does on many real devices Press a number key multiple times to get the letter you want For example press the 5 key twice for the letter K When you are entering text the asterisk key switches between upper case lower case numbers and symbols The indicator at the top of the screen shows your current mode The pound key enters a space Alternately you can just type on your keyboard to enter text Although this is convenient for entering text you must remember that it is a convenience your users will most likely be lacking Setting Emulator Preferences You can adjust the emulator settings to more closely resemble a specific device or to tes
12. m 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 88 J2ME Wireless Toolkit User s Guide October 2004 Video Capture Simulation simulates viewing input video such as might be possible on a device equipped with a camera m 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 In addition Simple Player parses ring tones in Ringing Tones text transfer language RTTTL See http www convertyourtone com rtttl html for information on RTTTL A key feature of Simple Player is a common set of commands that control media playback The commands are available from the Simple Player menu and some have associated keypad buttons The following table describes these commands TABLE10 Simple Player commands Command Key Description Mute 0 Turns off sound but the file continues to play This command Unmute toggles to Unmute Volume and Increases or decreases loudness META Data Displays information provided by the media file such as copyright information title and track list Stop in 5 Pauses the audio play in five seconds when set during seconds playback Rate 4and Alters the rate of speed of playbac
13. 500000 bytes You ll see a table with the following columns Chapter 5 Monitoring Applications 3 Name The class name of the objects Live The number of instances Some of these might be eligible for garbage collection Total The total number of objects that have been allocated since the application began Total Size The total amount of memory used by the objects m Average Size The average object size calculated by dividing the live instances into the total size Click on any column header to sort on that column You can search for a specific class name by choosing View gt Find from the memory monitor window menu Saving and Loading Memory Monitor Information To save your memory monitor session click on the Save button Choose a file name To load a memory monitor session choose File gt Utilities from the KToolbar menu Click on Open Session in the Memory Monitor box When you select a file the memory monitor window appears with all the session information Using the Network Monitor MIDP applications at a minimum are capable of HTTP network connections but many other types of network connections are also possible The network monitor provides a convenient way to see the information your application is sending and receiving on the network This is helpful if you are debugging network interactions or looking for ways t
14. Demonstrations 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 The demonstrations that are new or enhanced in this release are marked with NEW The goal of these demonstrations is to give you a glimpse of the API features of the emulator and the enhancements throughout the toolkit Most demonstration applications are simple to run The next section contains instructions for running most demonstrations Demonstrations that have additional documentation are linked in the table below The source code for every demonstration application is available in the toolkit apps directory Subdirectories contain projects and each project has a src directory that contains Java source code For example if the toolkit is installed in 79 A 1 WTK22 the source code for the SMS sender MIDlet example sms SMSSend in WMADemo is contained in WTK22 apps WMADemo src example sms SMSSend java Special Instructions Section A 3 Section A 4 Section A 5 Section A 6 Section A 7 Section A 8 Description Demonstrates audio capabilities including mixing and playing audio with an animation Demonstrates device discovery a
15. Storage wna Security BluetocthiOBex Storage root directory storage Storage size 8 kB Heap Size 256 kB OK Cancel Storage and Cleaning The emulator has persistent storage which by default is placed in toolkit appdb skin in files with a db extension For example the persistent storage for the DefaultColorPhone emulator skin is stored in toolkit appdb DefaultColorPhone There is no limit on the size of the persistent storage 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 Chapter 4 Using the Emulator 3 4 3 2 4 3 3 The toolkit enables you to choose a different location for the storage files and you can limit the size of the storage This is useful if you wish to test your application s behavior when a small amount of persistent storage is available To adjust the persistent storage settings choose Edit gt Preferences and click on the Storage tab Enter the name of the directory you wish to use for persistent storage You can only enter a relative path and the directory you specify is created in the toolkit appdb directory If you wish you can enter a limit in kilobytes for the size of the persistent storage Bear in mind that the storage implementation has s
16. Toolkit from the command line Appendix C describes internationalization features in the JIME Wireless Toolkit Preface xi Typographic Conventions Examples Edit your login file Use 1s a to list all files 9 You have mail 9 su Password Read Chapter 6 in the User s Guide These are called class options You must be superuser to do this To delete a file type rm filename In the book toolkit always refers to the installation directory of the JIME Wireless Toolkit Meaning The names of commands files and directories on screen computer output What you type when contrasted with on screen computer output Book titles new words or terms words to be emphasized Command line variable replace with a real name or value Variable file names and directories Typeface AaBbCc123 AaBbCc123 AaBbCc123 AaBbCc dir Accessing Documentation Online The following sites provide technical documentation related to Java technology http developer sun com http java sun com docs 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 xii 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
17. Toolkit installation Once ProGuard is installed you can use it by choosing Project gt Package gt Create Obfuscated Package In some cases you will need to provide a script file that controls how the obfuscator works If you are loading classes using Class forName for example you need to tell ProGuard to leave the class names unchanged Create a script file using a text editor then save it under the project s main directory Consult the ProGuard documentation for information on script files Next you need to tell the toolkit how to find this file To do this edit toolkit wtklib platform ktools properties where platform is the name of your underlying platform most likely Windows or Linux Add a line as follows obfuscate script name scriptfile 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 1 Go to the RetroGuard web site http www retrologic com retroguard main html 2 Download the latest version 3 Extract the ret roguard jar file from downloaded zip file to the bin directory of your J2ME Wireless Toolkit installation 4 Edit toolkit wtklib platform ktools properties so that it uses the RetroGuard obfuscator plug in obfuscator
18. 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 CHAPTER 1 Quick Start If you d like to get started right away try the demonstration applications that are included with the J2ME Wireless Toolkit To run the demonstrations start KToolbar On Windows you ll do this by choosing Start gt Programs gt J2ME Wireless Toolkit 2 2 gt KToolbar You ll see a window like this 1 Depending on how Windows is configured you might need to choose Start gt All Programs instead of Start gt Programs 1 1 FIGURE 1 The KToolbar window ENI J2ME Wireless Toolkit 1O x File Edit Project Help New Project E Open Project Device DefauttColorPhone y settings 2 Build za Clear Console Create a new project or open an existing one Next click on the Open Project button to open a demonstration application You ll see a list of all the available applications Pick one of them and click on the Open Project button in the dialog Once the application is open all you need to do is press the Run button The emulator will pop up running the example application Most demonstrations are self explanatory but some have additional instructions See Appendix A Application Demonstrations for addition
19. by the toolkit to store compiled class files lib Place a third party library in this directory to include it in this project res Images sounds and other resource files go in this directory They are packaged into the root of the MIDlet suite JAR src Place source files in this directory tmpclasses This directory is used by the toolkit tmpsrc This directory is used by the toolkit In addition the project directory contains a project properties file which contains information about the project If you want to remove temporary directories and files from the project choose Project gt Clean from the KToolbar menu 3 9 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 Chapter 3 Working With Projects 5 3 6 When you use a third party library in your application your JAR will expand by the size of the third party library You can use an obfuscator to reduce the code size and a good obfuscator will even eliminate whatever parts of the library you are not using Even with the use of an obfuscator a third party library will probably still be larger than your own custom code carefully written from scratch You have to evaluate the tradeoff between reduc
20. environment running on the same window system For example in an English window system the encoding setting is microedition encoding 1S08859_1 You can override the default value by adding the microedition encoding property to the toolkit wtklib platform ktools properties file For example if you want to use UTF 8 as the default setting on Windows you can set the property in the toolkit wtklib Windows ktools properties file as follows microedition encoding UTF 8 For more information on character encoding see the CLDC specification C 3 116 J2ME Wireless Toolkit User s Guide October 2004 Note All the 25 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 Gol Java Compiler Encoding Setting The javac encoding property determines the encoding used by the javac compiler to compile your source files The property s value is set to the default encoding for the J2SE environment running on the same window system You can override the default value by adding the javac encoding property to the toolkit wtklib platform ktools properties file where platform is the name of the underlying platform like Windows or Linux For example if you are running in an English system but find you need to compile a Japanese resource bundle you can specify a Japanese character set such as
21. equivalents and the relevant class from MMAPI Note that a short list of commands and the corresponding keypad buttons is available in the Simple Player application itself Just choose the Quick Help command from the menu Pausing AudioTest 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 or Not Well Behaved Pause the MIDlet by choosing MIDlet gt Pause from the emulator window s menu As expected the MIDlet is paused and no message is displayed on the KToolbar console Restart the MIDlet by choosing MIDlet gt Resume from the emulator window s menu Now choose the Misbehave command Pause the MIDlet again In the KToolbar console you will receive a short lecture about how well behaved MIDlets release resources when they are paused Video The Video application illustrates how the emulator is capable of playing animated GIF files and capturing video On a real device with a camera video capture can be used to show the user what the camera sees A 6 3 A 6 4 90 J2ME Wireless Toolkit User s Guide October 2004 Animated GIFs and video capture can be implemented using either a Form Item or a Canvas The Video demonstration includes all the possibilities m Animated GIF Form jar sh
22. hard disk that you wish to send as parts of the MMS message Click Add to add a file to the message Use the file browser to find the file you want to send and click OK Appendix A Application Demonstrations 101 FIGURE 61 Adding parts to an MMS message 5550001 Send a Message MMS Header Parts Fie Content Loce _Contenti gt Mime Type Encoding Size C Transferisa sargent millet O limagedpng Cp1252 26428 Total Size 26426 Send Cancel 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 FIGURE 62 WMADemo receives the image Message Subject Millet s Garden by John Singer Sargent Date Tue Jun 08 12 27 34 UTC 2004 Content Content Type image png Content sargent millet png 102 J2ME Wireless Toolkit User s Guide October 4 APPENDIX B Command Line Reference This appendix describes how to operate the J2ME Wireless Toolkit from the command line and details the steps required to build and run an application It also describes the J2ME Wireless Toolkit certificate manager utility called MEKeyTool and the MIDlet signing utility called JAD Tool Java Application Descriptor Tool Prerequisites Before building and running an application from the command line verify that you have a version no earlier than 1 4 2 of the J2SE SDK Run the jar exe command make sure the command is in your PAT
23. in the MIDP specification You can use any text editor to create the JAD file This file must have the extension jad Note You need to set the MIDlet Jar Size entry to the size of the JAR file created in the previous step Appendix Command Line Reference 105 B 2 2 For example a JAD file might have the following contents MIDlet Name MyMIDlet MIDlet Vendor My Organization MIDlet Version 1 0 MIDlet Jar URL MyApp jar MIDlet Jar Size 24601 Run 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 emulator options The general options are help Display a list of valid options version Display version information about the emulator Xquery Print emulator skin information on the standard output stream and exit immediately The information includes the skin name screen size and other capabilities Options that pertain to running MIDlet suites are Xdevice lt skin_name gt Run an application on the emulator using the given skin name For a list of skin names see Chapter 4 Using the Emulator Xdescriptor lt jad_file gt Run an application locally using the given JAD file classpath lt classpath gt Specify the classpath for libraries required to run the application Use this option when running an application locally D lt runtime_property gt Set the HT
24. ip ppd Refresh Rate 30 frames sec 1 30 IV Enable VM speed emulation ke VM Speed 762 bytecodes mnillisecond sa 0 SU 1000 100 IV Enable network throughput emulation 9600 z bits sec OK Cancel 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 If you choose a Periodic type you will also need to specify the Refresh Rate To simulate the slower speed of a real device check Enable VM speed emulation and choose the speed you want You can adjust the simulated network speed by checking Enable network throughput emulation and choosing a speed Pausing and Resuming MIDlets have a life cycle that is defined by the MIDP specification MIDlets can be started and stopped by the device Furthermore external events like incoming phone calls can cause the device to pause a MIDlet The emulator provides a simple mechanism to pause and resume running MIDlets This is very helpful for testing your application s behavior when it is paused Chapter 4 Using the Emulator 35 4 4 When the emulator is running choose MIDlet gt Pause from the emulator window s menu The running MIDlet is paused and the screen displays an Incoming Call me
25. monitor A D mmademo The mmademo application contains four MIDlets that showcase the multimedia capabilities of the 21 15 Wireless Toolkit This section describes the MIDlets and includes additional information about using multimedia from your applications Appendix A Application Demonstrations 7 A 6 A 6 1 Simple Tones The Simple Tones example demonstrates how to use interactive synthetic tones The first menu entries play tones with different pitch and duration using Manager playTone Choosing the third menu item will play a chord on the interactive MIDI device locator device midi The shortMidiEvent method of MIDIControl is used to trigger the notes of the chord A 6 2 Simple Player The Simple Player application demonstrates the range of audio and video capabilities of the emulator It includes example files in a variety of formats and can play files from the emulator s persistent storage or from HTTP URLs The player portion uses a generic javax microedition media Player interface The player displays duration media time and controls for running the media file If metadata is available in a file the player enables you to view the information such as author and title In the case of MIDI files if karaoke text is present in the file it displays on the screen during play Graphical user interface controls can be viewed on the display screen if applicable You can access these controls by selecting one of th
26. now includes the application you just installed Chapter 2 Developing MIDlet Suites 3 FIGURE 11 The application menu again 0 Install Application 7 Tiny Run via OTA is an extremely useful mechanism that makes it easy to install your MIDlet suite on the toolkit emulator Some features must be tested using this technique including the push registry and the installation of signed MIDlet suites If you want to test your MIDlet suite on a real device you ll need to install it first How this happens depends heavily on the device you are using There are two likely possibilities a You can deploy the application on a web server then transmit the application from server to device using the Over the Air OTA protocol described in the MIDP 2 0 specification This is most likely the same mechanism that users will encounter when they go to purchase or install your application You might be able to transfer the MIDlet suite to the device using a Bluetooth infrared or serial connection This is quite a bit simpler than running a web server and although it won t give you any insights into the process of installing your application on the device via OTA it allows you to see how your application performs on the device Run Once the application is installed running it is simple Just choose the application from the list and choose Launch from the menu 233 14 J2ME Wireless Toolkit User s Guide October 2004
27. runner class name com sun kvem ktools RunRetro obfuscator runner classpath wtklib ktools zip Retroguard will be used when you create an obfuscated package To switch back to ProGuard edit the obfuscator lines in the ktools properties file as follows obfuscator runner class name com sun kvem ktools RunPro obfuscator runner classpath wtklib ktools zip If you want to use a different obfuscator you ll have to implement an obfusctor plug in yourself See the J2ME Wireless Toolkit Basic Customization Guide for an example of how to implement an obfuscator plug in J2ME Wireless Toolkit User s Guide October 2004 16 Using a Debugger A variation on running your application is running it with a debugger A debugger allows you to monitor the running application more closely set breakpoints and examine variables You will need to supply your own debugger You can use the jdb debugger from J2SE or another debugger of your choice Begin by choosing Project gt Debug from the KToolbar menu Enter the TCP IP port number that the debugger will use to connect to the emulator Click on Debug The emulator begins running and waits for a connection from a debugger Start up your debugger and attach it to the port you specified Make sure to set the remote debugger to run in remote mode and to use TCP IP For more information consult the debugger s documentation Information about using jdb with the J2ME Wireless Toolkit is
28. the APIs you want to use To see how this works launch KToolbar and open a project Then click on Settings to bring up the following window 19 3 1 FIGURE 13 The project settings window mt Settings for project BluetoothDemo nil Required Optional User Defined MiDlets Push Registry Permissions Target Platform irm JT Profiles MIDP 2 0 Configurations 6 CLDC 1 0 C 41 Optional Wireless Messaging API 1 1 JSR 120 I Mobile Media API JSR 135 Additional APIs I Wireless Messaging API 2 0 JSR 205 Web Service Access for J2ME JSR 172 I PDA Profile for J2ME JSR 75 V Bluetooth OBEX for J2ME JSR 82 T Mobile 3D Graphics for J2ME JSR 184 On the API Selection tab the Target Platform setting controls the appearance of the rest of the tab Choose the setting that best suits your need and tweak your selection with the controls below For example if you re developing applications for JTWI compliant devices choose JTWI from the combo box Then use the controls below to specify which version of CLDC you want to use and whether MMAPI should be present The toolkit applies your selections when you compile your source code Note API selections do not apply to the emulator The emulator always supports all the available APIs The API selections you make in the project settings apply only to building a project In essence the API selections choose which c
29. the command line tool to manage J2SE keystores JadTool is packaged in a JAR file To run it open a command prompt change the current directory to toolkit bin and enter the following command java jar JADTool jar lt command gt The commands are as follows help Print the usage instructions for JADTool addcert keystore lt keystore gt alias lt alias gt storepass lt password gt certnum lt number gt chainnum lt number gt inputjad lt input_jadfile gt output jad lt output_jadfile gt Add the certificate of the key pair from the given keystore to the JAD file The default keystore is toolkit appdb _main ks addjarsig jarfile lt jarfile gt keystore lt keystore gt alias lt alias gt storepass lt password gt keypass lt password gt input jad lt input_jadfile gt output jad lt output_jadfile gt Add the digital signature of the given JAR file to the specified JAD file The default value for jarfile is the MIDlet Jar URL property in the JAD file The default ME keystore is foolkit appdb _main ks showcert certnum lt number gt chainnum lt number gt 811 encoding lt encoding gt input jad lt filename gt Display the list of certificates in the given JAD file The default value for encoding is UTF 8 jarfile is the MIDlet Jar URL property in the JAD keystore is SHOMEPATH S keystore certnum is 1 chainnumis 1 AppendixB Command Line Reference 1
30. to use the Run via OTA feature to install the application into the emulator in a process that mirrors how applications are installed on real devices If you don t know how to do this read about it in Chapter 2 Developing MIDlet Suites 9 98 J2ME Wireless Toolkit User s Guide October 2004 To see the magic of the push registry use the WMA console to send the emulator a message Launch the console by choosing File gt Utilities from the KToolbar menu Click on the Open Console button in the WMA box to launch the WMA console Click on the Send SMS button in the WMA console window Choose the number that corresponds to the emulator probably 5550000 If you re not sure what number the emulator is using look in its title bar Choose the number in the SMS message window then fill in a port number of 50000 Then type in your text message and click on Send FIGURE 57 Sending a text message 2 5550001 Send a Message SMS xi Text SMS Binary sms To Selected Clients Add Unlisted Client 5550001 Port Optional 50000 Message I need a sign to let me know you re here Cause my T set just keeps it all from being clear Clear Send Cancel The emulator will spring to life First it politely asks if it can launch the WMADemo application Appendix A Application Demonstrations 99 FIGURE 58 The push registry springs to life Information is arriving for W
31. 61 20 72 6f q Mama pajama roll 10 65 64 20 65 75 74 20 65 66 20 62 65 64 20 led out of bed an 20 64 20 73 68 65 20 72 61 66 20 74 65 20 74 4 she ran to the 30 20 70 65 6c 69 63 65 20 73 74 61 74 69 5 police station I Fiter T Fiter Settings Sort By Time x Number of shown messages 1 out of 1 64 J2ME Wireless Toolkit User s Guide October 2004 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 CHAPTER 8 Supported Formats and Protocols The emulator s MMAPI implementation supports the following media types TABLE 6 Supported MMAPI media formats MIME Type Description audio midi MIDI files audio sp midi Scalable Polyphony MIDI audio x tone seq MIDP 2 0 tone sequence audio x wav WAV PCM sampled audio image gif GIF 89a animated GIF video mpeg MPEG video video vnd sun rgb565 Video capture 65 8 1 Using MediaControlSkin The J2ME Wireless Toolkit comes with an emulator skin MediaControl1Skin that is focused on multimedia playback and control The skin includes buttons with symbols representing play stop volume up and volume down and other commands To see the usefulness of MediaControlSkin try it out with the mmademo d
32. 7 2 Simulating an Unreliable Network 58 7 3 Sending Messages With the WMA Console 9 7 3 1 Sending 8 Text SMS Message 59 7 3 2 Sending a Binary SMS Message 60 7 3 3 Sending Text or Binary CBS Messages 1 7 3 4 Sending MMS Messages 2 7 4 Receiving Messages in the WMA Console 3 7 5 Using the Network Monitor with WMA 4 8 Using the Mobile Media API 65 8 1 Supported Formats and Protocols 65 8 2 Using MediaControlSkin 6 8 3 Media Capture 66 Contents v 8 4 Well Behaved MIDlets 6 9 Working With Mobile 3D Graphics 7 9 1 JSR184 Overview 67 9 2 Immediate Mode 67 9 3 Retained Mode 68 9 4 Trading Quality forSpeed 68 9 5 Creating Mobile 3D Graphics Content 69 10 Using the PIM and FileConnection APIs 1 10 1 The FileConnection API 1 10 2 The PIM API 72 11 Using the Bluetooth and OBEX APIs 3 11 1 Bluetooth Simulation Environment 3 11 2 OBEX Over Infrared 73 11 3 Setting OBEX and Bluetooth Preferences 74 11 3 1 OBEX Preferences 74 11 3 2 Bluetooth Discovery Timeout 75 11 3 3 Bluetooth System Properties 75 11 3 4 Bluetooth BCC Properties 75 12 Using Web Services 77 A Application Demonstrations 79 A 1 Overview 79 A 2 General Instructions 1 A 3 BluetoothDemo 82 A4 Demo3D 83 A 4 1 Life3D 83 A 4 2 PogoRoo 84 A 4 3 retainedmode 5 A 5 JSR172Demo 6 A 6 mmademo 86 J2ME Wireless Toolkit User s Guide October 2004 A 6 1 Simple Tones 7 0 6 2 Simple Player 7 A 6 3 PausingAudioTest 9 A 6 4 Video 89 A 6 5 Attributes formm
33. H and then run java version at the command line to verify that the version of the J2SE SDK that is actually being used is 1 4 2 For more examples see the files build bat and run bat in the bin directories of the demonstration applications You can find these files under the toolkit apps lt demo gt bin directory where toolkit is the installation directory of the J2ME Wireless Toolkit and lt demo gt is the name of one of the demo applications B 1 The Development Cycle For a full description of developing MIDP applications see Chapter 2 Developing MIDlet Suites This section describes how to accomplish each of the steps in the development cycle from the command line 103 B 2 Build Using KToolbar building a project is a single step Behind the scenes however there are actually two steps First Java source files are compiled into Java class files Next the class files are preverified which means they are prepared for the CLDC KVM Use the javac compiler from the J2SE SDK to compile Java source files You can use the existing J2ME Wireless Toolkit project directory structure You ll need to use the bootclasspath option to tell the compiler to use the MIDP APIs and you ll use the d option to tell the compiler where to put the compiled class files The following example shows how you could compile a MIDP 2 0 application taking source files from the src directory and placing the class files in the tmp
34. IDlet 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 6 3 Signing a MIDlet Suite To sign a MIDlet suite you must package it first Then choose Project gt Sign from the KToolbar menu The signing window appears Chapter6 Security and MIDlet Signing 1 FIGURE 26 The MIDlet suite signing window sign Miet suite Ti Action Sign MIDlet Suite New Key Pair Generate CSR Import Certificate Import Key Pair lias List J2SE Key Details Creation Date Tue Mar 04 02 34 21 EST 2003 Certificate chain length 1 Certificate 1 Subject O myserver C My Company Issuer O myserver C My Company Serial number 3e6456fd Valid from Tue Mar 04 02 34 21 EST 2003 to Tue Nov 29 02 34 21 EST Certificate fingerprints 105 11 81 6a ba 50 Sb 6 8 1 71 54 SHA 07 02 12 82 88 80 98 65 76 08 96 3 2b 3a 76 22 4b 54 a4 ree 4 Signing is very easy Just select the key you want to use in the Alias List and click on the Sign MIDlet Suite button 6 4 Managing Keys The MIDlet signing window can also be used to manage keys 6 4 1 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 a
35. Java source file Chapter 3 Working With Projects 7 5 7 1 Aad 3 7 3 28 J2ME Wireless Toolkit User s Guide October 2004 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 does not represent a specific device but it provides correct implementations of its supported APIs CHAPTER 4 Emulator Skins A skin is a thin layer on top of the emulator implementation that provides it with a certain appearance screen characteristics and input controls The J2ME Wireless Toolkit comes with skins that represent different kinds of devices TABLE 3 Emulator skins Name Screen size Canvas size Colors Input DefaultColorPhon 240 x 320 240 x 289 4096 ITU T e DefaultGrayPhone 180 x 208 180 x 177 4096 ITU T MediaControlSkin 180 x 208 180 x 177 4096 ITU T QwertyDevice 636 x 235 540 x 204 4096 Qwerty You can create your own emulator skins if you wish See the Basic Customization Guide for details 29 4 1 4 2 Using the Emulator 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 30 J2ME Wireless Toolkit User
36. L EXPRESS OR IMPLIED CONDITIONS REPRESENTATIONS AND WARRANTIES INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT ARE DISCLAIMED EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID Copyright 2004 Sun Microsystems Inc 4150 Network Circle Santa Clara California 95054 Etats Unis Tous droits r serv s 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 Les produits qui font l objet de ce manuel d entretien et les informations qu il contient sont regis par la legislation americaine en matiere de controle des exportations et peuvent etre soumis au droit d autres pays dans le domaine des exportations et importations Les utilisations finales ou utilisateurs finaux pour des armes nucleaires des missiles des armes biologiques et chimiques ou du nucleaire maritime directement ou indirectement sont strictement interdites Les exportations ou reexportations vers des pays sous embargo des Etats Unis ou vers des entites figurant sur les listes d exclusion d exportation americaines y compris mais de maniere non exclusive la li
37. MA Demo Is it OK to jaunch AMA Demo VVMA Demo needs to start self to check to see if it has received Choose Yes The SMSReceive MIDlet is launched and immediately displays the incoming SMS message FIGURE59 An incoming text message need a sign to let me know you re here Cause my TY set just keeps it all from being lear You can also use the WMA console to send and receive CBS and MMS messages See Chapter 7 Using the Wireless Messaging API for more information J2ME Wireless Toolkit User s Guide October 2004 100 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 Leave the emulator running In the WMA console click on Send MMS to pop up the MMS composition window Fill in a message subject the application ID example mms MMSDemo and the telephone number of the running emulator FIGURE60 Addressing an MMS message ZM 5550001 Send a Message MMS a x Header Parts Subject milets Garden by John Singer Sargent Application ID example mms MMSDemo Add Remove Send Cancel Next click on the Parts tab The WMA console allows you to select files from your
38. P be sure to include the relevant jar files in the classpath Package To package a MIDlet suite you must create a manifest file an application JAR and finally a MIDlet suite descriptor Create a manifest file containing the appropriate attributes as specified in the MIDP specification You can use any text editor to create the manifest file A manifest might have the following contents for example MIDlet 1 My MIDlet MyMIDlet png MyMIDlet MIDlet Name MyMIDlet MIDlet Vendor My Organization MIDlet Version 1 0 MicroEdition Configuration CLDC 1 0 MicroEdition Profile MIDP 2 0 Create a JAR file containing the manifest as well as the suite s class and resource files To create the JAR file use the jar tool that comes with the J2SE SDK The syntax is as follows jar cfm lt file gt lt manifest gt cC lt class_directory gt C lt resource_directory gt The arguments are as follows lt file gt The JAR file to create lt manifest gt The manifest file for the MIDlets lt class_directory gt The directory containing the application s classes lt resource_directory gt The directory containing the application s resources For example to create a JAR file named MyApp jar whose classes are in the classes directory and resources are in the res directory use the following command jar cfm MyApp jar MANIFEST MF C classes C res Create a JAD file containing the appropriate attributes as specified
39. TP and HTTPS proxy servers Valid properties include com sun midp io http proxy lt proxy host gt lt proxy port gt Xjam lt command gt lt application gt Run an application remotely using the Application Management System AMS to run using OTA provisioning If no application is specified with the argument the graphical AMS is run install lt jad_file_url gt force list storageNames Install the application with the specified JAD file onto a device run lt storage_name gt lt storage_number gt Run a previously installed application The application is specified by its valid storage name or storage number B 2 3 106 J2ME Wireless Toolkit User s Guide October 2004 remove lt storage_name gt lt storage_number gt 1 Remove a previously installed application The application is specified by its valid storage name or storage number Specifying a11 all previously installed applications are removed transient lt jad_file_url gt 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 B 2 4 Debugging You can use the following options with the emulator for debugging and tracing Xverbose lt trace_options gt Display trace output as specified by a list of comma separated options class trace class loading gc trace garbage collection all use all tracing options Xdebug Enable
40. The wtk locale property should be placed in the toolkit wtklib platform ktools properties file where platform is the name of the underlying platform Windows or Linux for example 115 C 1 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 For example If you are running in an English system in the US the microedition locale is set to en US If you are running in a French system the microedition locale is set to fr FR For information on microedition locale consult the MIDP specification You can override the default value by adding the microedition locale property to the file toolkit wtklib platform ktools properties file and define the property as desired as shown in the following examples microedition locale en US microedition locale null For details on setting a default locale see the J2ME Wireless Toolkit Basic Customization Guide C 2 Character Encodings The CLDC system property microedition encoding defines the default character encoding name of the MIDP environment In the J2ME Wireless Toolkit emulator this property is set according to the underlying window system you are using The property s value is set to the default encoding for the J2SE
41. Toolbar advanced configuration options 26 application directory 27 starting 1 5 ktools properties 27 ktools properties file 115 L libraries 25 M managing certificates from command line 112 manifest file creating 105 memory monitor 42 graph 42 object details 43 messages sorting 46 messaging network simulation 58 method profiling 39 microedition encoding property 116 microedition locale property 116 MIDlets in projects 23 MIME types 17 Mobile 3D Graphics API 67 120 J2ME Wireless Toolkit User s Guide October 4 121 Index push registry 24 R remotely deployed applications 17 revision control 27 revision control files 27 Revision Control System RCS 27 RevisionControl property 27 run options 106 Run via OTA 12 51 running from command line 106 S signed MIDlet suites 49 signing MIDlet suites 51 SMS binary message sending 60 SMS text message sending 59 source code creating 7 location 6 supported APIs 3 T Target Platform 20 tracing options 107 V version control 27 version optopn 106 W Wireless Messaging API WMA 57 Wireless Toolkit certificate manager utility 103 running from command line 103 Wireless Toolkit setting locale 115 WMA console 59 wscompile tool 113 wtk locale property 115 X Xdebug option 107 Xquery option 107 Xrunjdwp option 107 Xverbose option 107 122 J2ME Wireless Toolkit User s Guide Octob
42. Y Ry SUN microsystems User s Guide J2ME Wireless Toolkit 2 2 Sun Microsystems Inc 4150 Network Circle Santa Clara California 95054 U S A 1 800 555 9SUN or 1 650 960 1300 October 2004 Copyright 2004 Sun Microsystems Inc 4150 Network Circle Santa Clara California 95054 U S A All rights reserved U S Government Rights Commercial software Government users are subject to the Sun Microsystems Inc standard license agreement and applicable provisions of the FAR and its supplements This distribution may include materials developed by third parties Sun Sun Microsystems the Sun logo Java J2ME and the Java Coffee Cup logo are trademarks or registered trademarks of Sun Microsystems Inc in the U S and other countries The Adobe logo and the PostScript logo are trademarks or registered trademarks of Adobe Systems Incorporated Products covered by and information contained in this service manual are controlled by U S Export Control laws and may be subject to the export or import laws in other countries Nuclear missile chemical biological weapons or nuclear maritime end uses or end users whether direct or indirect are strictly prohibited Export or reexport to countries subject to U S embargo or to entities identified on U S export exclusion lists including but not limited to the denied persons and specially designated nationals lists is strictly prohibited DOCUMENTATION IS PROVIDED AS IS AND AL
43. a graphic designer or artist uses 3D modeling software to create a scene graph The scene graph is saved in the JSR 184 file format The scene graph file is bundled with the application At runtime the application uses the scene graph API to load and display the file Applications can manipulate parts of a loaded scene graph to animate characters or create other effects The basic strategy is to do as much work as possible in the modeling software At runtime the application can grab and manipulate parts of the scene graph which can also include paths for animation or other effects For an example of retained mode see the retainedmode MIDlet in the Demo3D example application Trading Quality for Speed One of the challenges of MIDP development is the constrained environment of typical devices Compared to desktop computers MIDP devices have slow processors and little memory These challenges extend into the arena of 3D graphics To accomodate a wide variety of implementations the JSR 184 specification provides various mechanisms to make the display of a 3D scene as efficient as possible One approach is scoping a technique where you tell the 3D graphics implementation when objects are not going to interact with each other For example if you defined a scene graph for a house you could use scoping to specify that the light in the basement doesn t affect the appearance of the bedroom on the second floor Scoping makes the impl
44. ackage 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 Devices can use the descriptor to learn about the application before downloading the entire JAR an important consideration in a memory lean bandwidth starved wireless world To ask the toolkit to package your MIDlet suite choose Project gt Package gt Create Package from the KToolbar menu The MIDlet suite descriptor and JAR are generated and placed in the bin directory of your project Packaging might involve additional steps You can use a code obfuscator to shrink the size of the MIDlet suite JAR a technique that is described later in this chapter In addition the J2ME Wireless Toolkit provides tools to allow you to cryptographically sign MIDlet suites See Chapter 6 Security and MIDlet Signing for more information Chapter 2 Developing MIDlet Suites 1 2 3 241 Install To properly test a MIDlet suite you should install it into the toolkit s emulator or a real device When you press the Run button in KToolbar the MIDlet suite is not installed into the emulator Instead the emulator runs the MIDlet classes directly The emulator also has the capability of installing applications into its me
45. ademo 90 A 7 ObexDemo 0 4 8 PDAPDemo 2 A 8 1 Browsing Files 2 A 8 2 The PIM API 4 A 9 WMADemo 97 Command Line Reference 103 B 1 Prerequisites 103 B 2 The Development Cycle 3 B 2 1 Build 103 B 2 2 Package 104 B 2 3 Run 6 B 2 4 Debugging 107 B 3 Launching Toolkit GUI Components 8 B 4 Setting Emulator Preferences 8 B 5 Using Security Features 0 B 5 1 Changing the Emulator s Default Protection Domain 0 B 5 2 Signing MIDlet Suites 1 B 5 3 Managing Certificates 2 B 6 Using the Stub Generator 113 B 6 1 Options 113 B 6 1 1 Example 114 Internationalization 115 C 1 Locale Setting 115 C 2 Emulated Locale 116 C 3 Character Encodings 116 C 3 1 Java Compiler Encoding Setting 117 Contents vii C 4 Font Support in the Default Emulator 7 Index 119 viii J2ME Wireless Toolkit User s Guide October 2004 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 Connected Limited Device Configuration CLDC If you need help getting started with Java programming try the New to Java Center http java sun com learning new2 java For a quick start with MIDP programming read Learning Path Getting Started with MIDP 2 0 http developers sun com techtopi
46. al details All the source code for the demonstration applications is available in the toolkit apps directory Each demonstration has its own project directory Inside the project directory the source files are in the src directory For example the source code for the games demonstration is in 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 A collection of utilities provides other useful functionality including a text messaging console and cryptographic utilities 1 2 2 J2ME Wireless Toolkit User s Guide October 2004 3 KToolbar is the center of the toolkit You can use it to build applications launch the emulator and start the utilities Alternately the emulator and utilities can be run by themselves which is useful in many situations If you want to demonstrate MIDP applications for example it s useful to run the emulator by itself 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 With the push of a button the toolkit compile
47. ame gt The filename you provide should be the full path name of a property file whose values override the values in the preferences dialog box The property file can contain the following properties TABLE 13 Emulator Preferences Properties List Property Name Property Description and Legal Values http version Network Configuration gt HTTP Version Value HTTP 1 1 HTTP 1 0 http proxyHost Network Configuration gt HTTP Address Value hostname http proxyPort Network Configuration gt HTTP Port Value integer https proxyHost Network Configuration gt HTTPS Address Value hostname https proxyPort Network Configuration gt HTTPS Port Value integer 108 J2ME Wireless Toolkit User s Guide October 4 Property Description and Legal Values Monitor gt Enable memory monitor Value true false Monitor gt Enable Comm monitoring Value true false Monitor gt Enable Datagram monitoring Value true false Monitor gt Enable HTTP monitoring Value true false Monitor gt Enable HTTPS monitoring Value true false Monitor gt Enable Socket monitoring Value true false Monitor gt Enable SSL monitoring Value true false Monitor gt Enable profiling Value true false Performance gt bits sec combo box Value integer Performance gt Enable network throughput emulation Value true false Performance gt Graphics primitives latency Value integer Performance
48. an application using the getProperty method in javax bluetooth LocalDevice The Bluetooth properties are fully described in the JSR 82 specification 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 properties are as follows TABLE 7 BCC properties Property Description Enable Bluetooth If this property is disabled then support LocalDevice getLocalDevice throws a BluetoothStateException and no connections can be created This is useful to test the behavior of your application on devices that support JSR 82 but may have the Bluetooth feature turned off Device is This property indicates whether or not this emulator can be discoverable discovered by other emulators Friendly name The friendly name is a human readable name for the emulator in the simulated Bluetooth environment If the name is left blank the emulator will not support the friendly name feature Encryption This property determines whether connection encryption is supported on or not off In addition the force settings means all connected must be encrypted See the documentation for RemoteDevice s encrypt method for details Authorization This is similar to the Encryption property See Remot eDevice s authorize method Authent
49. ance Monitor Storage wna Security Bluetooth OBEX OBEX Maximum packet length Jose bytes Discovery timeout ht 0000 ms r Bluetooth Internal Properties System Properties BCC Properties Device discovery timeout fi 0000 ms The changes will take effect the next time the emulator is executed OBEX Preferences Devices using IrDA in the real world discover other devices by listening You can configure how long the J2ME Wireless Toolkit emulator waits to discover another device using the Discovery timeout field in the IrDA OBEX section of the preferences window Enter a value in milliseconds At the API level the discovery timeout value determines how long a call to Connector open irdaobex discover will block before it returns or throws an exception The maximum packet length affects how much data is sent in each packet between emulators Shorter packet values will result in more packets and more packet overhead 11 3 11 3 1 74 J2ME Wireless Toolkit User s Guide October 2004 Bluetooth Discovery Timeout In the Bluetooth section of the preferences window the Device discovery timeout is the amount of time in milliseconds the emulator will wait while attempting to locate other devices in the simulated Bluetooth environment Bluetooth System Properties The System Properties tab in the Bluetooth section of the preferences contains properties that can be retrieved in
50. ansferred over the simulated infrared link and displayed on the first emulator FIGURE 49 A successfully transferred image Appendix A Application Demonstrations 3 A 8 PDAPDemo PDAPDemo shows how to use the PIM and FileConnection APIs that are part of the JSR 75 specification A 8 1 Browsing Files To run the file browser you ll need to give the MIDlet appopriate security authorization The easiest way to do this is to choose Edit gt Preferences from the KToolbar menu Click on the Security tab Change the Security domain to trusted and press OK Now open and run the PDAPDemo project Launch the FileBrowser MIDlet You will see a directory listing You can browse through the available directories and files By default there is one directory root1 FIGURE 50 Browsing files ooti Select a directory and press the select button to enter it The root1 directory contains a single file Readme 94 J2ME Wireless Toolkit User s Guide October 2004 95 FIGURE 51 Contents of the root1 directory 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 FIGURE 52 Viewing file properties and contents Location root1 This is a demo for the File Connection optional Type Regular File package of the JSR75 Modified 6 3 34 24 May 2004 Attributes MiRead Bivwrite Hidden Appendix A Application Demons
51. at a time You can create a new project or open an existing project In this chapter you will work with a very simple example project As you read about each step in the development cycles you can work along in the toolkit To create a new project first start KToolbar On Windows choose Start gt Programs gt J2ME Wireless Toolkit 2 2 gt KToolbar You ll see the KToolbar window 2 Depending on how Windows is configured you might need to choose Start gt All Programs instead of Start gt Programs 24 FIGURE2 The 1001082 window Bat J2ME Wireless Toolkit File Edit Project y New Project Open Project Settings Build p Run Device DetauitColorPhone za Clear Console Create a new project or open an existing one Click on New Project The toolkit will ask you for the name of the project and the name of the MIDlet class you will write Fill in the names and click Create Project FIGURE3 Creating a new project TAT J2ME Wireless Toolkit 0 x File Edit Project Qs New Project i Project Q Settings Build Bp Run clear Device a 1471 1 Sat Project Name riny MiDlet Class Name Tinyraiet Create Project Cancel The project options automatically pop up allowing you to set up the build environment for the project The default options are fine for this example just click on OK to dismiss
52. classes directory Newlines have been added for clarity javac bootclasspath lib cldcapil0 jar lib midpapi20 jar d tmpclasses src java If you want to use the optional APIs that are supported by the toolkit add their 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 preverify command is as follows preverify options lt files directories gt Some of the options are as follows classpath lt classpath gt Specify the directories or JAR files given as a semicolon delimited list from which classes are loaded d lt output directory gt Specify the directory into which the preverifier should output classes This directory must exist before preverifying If this option is not used the preverifier places the classes in a directory called output Following the example for compiling use the following command to verify the compiled class files As before newlines have been added for clarity preverify classpath lib cldcapil0 jar lib midpapi20 jar d classes tmpclasses B 2 1 104 J2ME Wireless Toolkit User s Guide October 2004 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 MID
53. cldcl 1 d generated config xml B 6 1 1 114 J2ME Wireless Toolkit User s Guide October 2004 APPENDIXC 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 In software a locale is represented by a collection of files data and code which contains the information necessary to adapt software to a specific location Some software uses a locale to tailor information for users such as Messages displayed to the user Fonts used or other writing specific information By default all KToolbar strings that is the entire User Interface UI are displayed in the language of the supported platform s locale For example Japanese characters can be displayed in KToolbar running on a Japanese Windows machine provided that the correct localized J2ME Wireless Toolkit has been downloaded and installed You can set the wtk locale property to have the KToolbar displayed in a specified locale s language For example you can have the toolkit running on a Japanese machine but still have the KToolbar display shown in English by setting the locale property to en US and making sure that the proper supplement has been downloaded and installed over the J2ME Wireless Toolkit
54. click on the Build button Assuming you saved your source file in the right place the toolkit will find it and compile it Compilation errors are displayed in the 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 22 2 8 J2ME Wireless Toolkit User s Guide October 2004 9 FIGURES Messages about building EAI J2ME Wireless Toolkit Tiny E x File Edit Project Help Qa New Project ILE Open Project amp Settings e aa 9 Run z Clear Console Device DefauttColorPhone symbol method append javax microedition lcdui Command location class javax microedition lcdui Form mainForn append exitCommand A l error con swn kvem ktools ExecutionException uild failed Project settings saved uilding Tiny uild complete xl 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 See the CLDC specification for more information on preverification Run Once the project builds successfully you are ready to try it out in the emulator Click on the Run button The emulator pops up and shows a list of all the MIDlets in your project
55. cludes two independent APIs The Bluetooth API provides an interface to Bluetooth wireless networking including device discovery and data exchange The OBEX API allows applications to use the Object Exchange OBEX protocol over Bluetooth or other communication channels This chapter describes how the J2ME Wireless Toolkit implements the Bluetooth and OBEX APIs Bluetooth Simulation Environment The J2ME Wireless Toolkit emulator allows you to develop and test application that use Bluetooth without having actual Bluetooth hardware The toolkit simulates a Bluetooth environment for running emulators Multiple emulator instances can discover each other and exchange data using the Bluetooth API For an example see the documentation of BluetoothDemo in Appendix A Application Demonstrations 11 1 OBEX Over Infrared The J2ME Wireless Toolkit implements OBEX transfer over simulated Bluetooth and infrared connections The simulated infrared connection follows the IrDA standard see http www irda org Simulated infrared transfers can take place between multiple running emulators 73 11 2 Setting OBEX and Bluetooth Preferences The J2ME Wireless Toolkit allows you to configure the Bluetooth and OBEX simulation environment Choose Edit gt Preferences from the KToolbar menu to see the following window FIGURE 38 Bluetooth and OBEX preferences xi Preferences for oi Network Configuration Perform
56. cs mobility learn midp midp20 Related Documentation This book is not a tutorial in MIDP programming nor is it a tutorial in programming any of the additional APIs that are supported by the toolkit This section lists related specifications Although specifications are definitive they are not always the most accessible kind of information For a variety of developer centered articles try Sun s mobility web site Preface ix http developers sun com techtopics mobility Title J2ME Wireless Toolkit Basic Customization Guide J2ME Wireless Toolkit Release Notes Mobile Information Device Profile for the J2ME Platform Mobile Information Device Profile 2 0 J2ME Connected Limited Device Configuration J2ME Connected Limited Device Configuration Wireless Messaging API WMA Mobile Media API Java Technology for the Wireless Industry J2ME Web Services Specification PDA Optional Packages for the J2ME Platform Java APIs for Bluetooth Mobile 3D Graphics API for J2ME Topic Customizing the J2ME Wireless Toolkit Release Notes MIDP 1 0 JSR 37 MIDP 2 0 JSR 118 CLDC 1 0 JSR 30 CLDC 1 1 JSR 139 WMA 2 0 JSR 205 MMAPI JSR 135 JTWI JSR 185 J2ME Web Services JSR 172 PDAP Optional Packages JSR 75 Bluetooth and OBEX JSR 82 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
57. e s associated protection domain Importing Certificates You can import certficates either from certificate files or from J2SE keystore files To import a certificate from a file click on Import Certificate in the certificate manager window After you locate the certificate file choose which protection domain is associated with the certificate To import a certificate from a J2SE keystore choose Action gt Import J2SE Certificate from the menu in the certificate manager window First choose a protection domain for the certificate Then select the keystore file and enter the keystore password Finally select the alias for the certificate you wish to import Chapter6 Security and MIDlet Signing 55 6 5 1 6 5 2 Removing Certificates To remove a certificate from the list select the certificate and choose Action gt Delete Selection 56 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 7 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 WMA 2 0 JSR 205 includes support for MMS messages as well This chapter describes the tools you can use to develop WMA applications It begins by showing how to configure the emulator s support of WMA Next you ll learn about the WMA console a handy uti
58. e manager utility 103 character encodings 116 classpath option 104 command line operations 103 command path 103 D debugging 17 from command line 107 debugging options 107 demonstrations 79 source code 2 deploying on a web server 17 descriptor 11 attributes 21 Mobile Media API MMAPI 65 capture 66 formats and protocols 65 N Network Monitor sorting messages 46 network monitor 44 filtering 45 sorting 46 using with WMA 64 O OBEX 73 preferences 74 obfuscation 15 installing ProGuard 15 installing RetroGuard 16 optional APIs 3 P packaging example from command line 105 packaging from command line 104 pausing and resuming 35 performance 34 permissions 49 persistent storage 33 Personal Information Management PIM API 71 phone number setting in emulator 57 preverifying 9 example from command line 104 profiler 39 call graph 40 41 projects 5 19 attributes 21 building 8 creating 6 deploying on real devices 14 directory structure 25 libraries 25 MIDlets 23 packaging 11 push registry 24 running 9 selecting APIs 19 source code 6 protection domains 49 50 proxy servers 32 IrDA 73 J JAD 11 attributes 21 creating 11 MIME type 17 JAR creating 11 MIME type 17 Java Cryptography Extension JCE keystore 112 JSR 184 67 JSR 75 71 K key management 52 key pair creating 52 importing 54 keytool utility 112 K
59. e media samples in Simple Player then pressing the Menu button to view and select the desired command The demo includes the following media samples Bong plays a short WAV file You can adjust certain playback features as described later in this document The display shows the duration of the sound in minutes seconds tenths of a second for example 00 17 5 This audio sample is a resource file in the MIDlet suite JAR file m MIDI Scale plays an example musical scale The display shows the title of the selected music file the duration of the song the elapsed time during playback and the current tempo in beats per minute bpm This MIDI file is stored in the MIDlet suite JAR file Simple Ring Tone plays a short sequence of Beethoven s Fifth Symphony The display shows the title of the selected music file the duration of the song the elapsed time in seconds and tenths of a second during playback and the current tempo in beats per minute bpm This ringtone file jts format is stored in the MIDlet suite JAR file m WAV Music plays a brief audio file The display shows the title of the audio file the duration of the audio the elapsed time during playback and the playback rate in percent This WAV file is retrieved from an HTTP server MIDI Scale plays 8 MIDI file that is retrieved from an HTTP server m The Animated GIF example shows an animated GIF that counts from 1 to 5 The file is stored in the MIDlet suite JAR
60. ee if there are specific instructions for a demonstration BluetoothDemo This application contains a MIDlet that demonstrate the use of JSR 82 s Bluetooth API Bluetooth Demo shows how images can be transferred between devices using Bluetooth You will need to run two instances of the emulator to see how this demonstration works In the first emulator choose Bluetooth Demo then Server The emulator will ask you if you want to allow a Bluetooth connection Choose Yes The server starts up and displays a list of images At the beginning none of the images are being made available on the 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 A 3 82 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 42 Running the Bluetooth Demo server E e Ono The leaf jpg The leat png 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 Choose Yes In the first emulator the server a prompt appears asking if you want to authorize the connection from the client Choose Yes The image is transferred via simulated Bluetooth and shown on the client emulator
61. ementation s job easier by reducing the number of calculations required to show a scene 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 9 4 68 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 Superscape http superscape com is one such vendor Because it is relatively difficult to create and manipulate 3D graphics content in an application using the immediate mode API most applications rely as much as possible on a scene graph file By putting as much as possible into the scene graph file at design time the application s job at runtime will be considerably simplified 69 Chapter 9 Working With Mobile 3D Graphics 9 5 70 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 0 Using the PIM and FileConnection APIs The J2ME Wireless Toolkit supports JSR 75 the PDA Optional Packages for the J2ME Platform JSR 75 incl
62. emonstration application 8 2 Media Capture The J2ME Wireless Toolkit emulator supports audio and video capture Audio capture is supported by using the capture capabilities of the system upon which the emulator runs Video capture is supported by simulating a camera input See the mmademo example application for details and source code that demonstrates how to capture audio and video 8 3 Well Behaved MIDIlets MIDlets have a life cycle that is defined in the MIDP specification MIDlets can be paused by events such as incoming phone calls A well behaved MIDlet releases important device resources when it is paused and reallocates or restarts those resources when the MIDlet is resumed In the MMAPI arena any Players that are rendering content should be stopped when a 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 See Appendix for details The warning message is printed once only for each running emulator 8 4 66 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 9 Working With Mobile 3D Graphics 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 functi
63. emory while your application runs The network monitor shows network data transmitted and received by your application It supports many network protocols including HTTP HTTPS SMS and CBS Tracing outputs low level information to the KToolbar console Note Monitoring features might slow down the execution of your application Using the Profiler The profiler keeps track of every method in your application For a particular run it figures out how much time was spent in each method and how many times each method was called After you finish running your application and shut down the emulator the profiler pops up allowing you to browse through the method call information To turn on the profiler choose Edit gt Preferences from the KToolbar menu Click on the Monitor tab If you are interested in seeing profiling information for all the system implementation methods check Show System Classes Otherwise the profiler shows only system methods that contain calls to your application methods 39 5 1 FIGURE 20 Turning on the profiler Preferences Xx Preferences for E Network Configuration Performance Monitor storage wma Security BluetoothiOBeX Memory Monitor Enable Memory Monitor Network Monitor T Enable Network Monitoring I Show System Classes Trace J Trace garbage collection I Trace class loading I Trace Exceptions J Trace method calls Lots of output
64. er 4
65. es file To see the effects of your changes restart KToolbar B07 26 J2ME Wireless Toolkit User s Guide October 2004 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 lt application_directory gt Any backslash characters in the directory s path should be preceded by another backslash Also the directory s path should not contain any spaces For example to set the application directory to D dev midlets you would use kvem apps dir D dev midlets Setting the javac Encoding Property By default the Java compiler uses the encoding set in the J2SE environment that you are running For information on how to override the default source file encoding see Appendix C Internationalization Working with Revision Control Systems Using the filterRevisionControl property you can configure KToolbar to recognize and ignore auxiliary files created by the SCCS RCS and CVS revision control systems To recognize and ignore auxiliary files include the following line in ktools properties kvem filterRevisionControl true As a result you prevent KToolbar from treating revision control files as source and resource files For example KToolbar would treat a file named src SCCS s MyClass java as being an SCCS revision control file and not a
66. es it to verify the signature on the MIDlet suite The MIDlet suite is installed into whatever protection domain you picked 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 Chapter6 Security and MIDlet Signing 3 6 4 2 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 2 Generate a Certificate Signing Request CSR Press Generate CSR in the signing window To change the location of the CSR file enter a new path or press Browse and choose a new file location Press Create to write the CSR file After the CSR is written you ll see a message that indicates success 3 Send the CSR to a certificate authority CA The CA will need more information from you to verify your identity You will also need to pay the CA for the certificate they generate for you 4 Once the CA has verified your identity and taken your money you will receive a certificate from the CA that certifies your public key 5 Import the certificate into the J2ME Wireless Toolkit by pressing Import Certificate in the MIDlet signing window Yo
67. file chooser Sending Text or Binary CBS Messages Sending CBS messages is similar to sending SMS messages except that you don t need to choose recipients To send a text or binary CBS message click on Send CBS in the WMA console The send window pops up Chapter 7 Using the Wireless Messaging API 93 FIGURE 33 Sending CBS messages 2M 5550000 Send a Message CBS x Text CBS Binary ces Message Identifier 77 Message ell this town has closed dow way too early d there s nothing to do Clear Cancel 7 3 4 Sending MMS Messages MMS messages consist of one or more files usually images or sounds MMS message can be sent to multiple recipients To send an MMS message from the WMA console click the Send MMS button The window for composing MMS messages has two tabs one for recipients and one for content Begin by filling in a subject and recipient If you wish to add more recipients click on the 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 62 J2ME Wireless Toolkit User s Guide October 2004 63 FIGURE 34 Adding recipients for an MMS message PM 5550000 Send a Message MMS x Remove_ To add media files to the message click on the Parts tab Click on Add to add a part to the message To remo
68. gt Display refresh radio button Value default immediate periodic Performance gt Display refresh slider Value integer Performance gt Enable VM speed emulation check box Value integer Performance gt Enable VM speed emulation slider Value true false Storage gt Storage root directory Value String relative path to appdb Storage gt Storage size Value integer MMedia gt Audio Capture Value true false MMedia gt MIDI tones Value true false Command Line Reference 9 TABLE 13 Emulator Preferences Properties List Property Name kvem memory monitor enable kvem netmon comm enable kvem netmon datagram enable kvem netmon http enable kvem netmon https enable kvem netmon socket enable kvem netmon ssl enable kvem profiler enable netspeed bitpersecond netspeed enableSpeedEmulation screen graphicsLatency screen refresh mode screen refresh rate vmspeed bytecodespermilli vmspeed enableEmulation storage root storage size mm control capture mm control midi Appendix B Property Description and Legal Values MMedia gt Audio Mixing Value true false MMedia gt Audio Record Value true false Value true false MMedia gt MIDI format Value true false MMedia gt Video format Value true false MMedia gt WAV Audio format Value true false WMA gt Phone Number of Next Emulator Value integer WMA gt First Assigned Ph
69. here Debugging MIDlets http developers sun com techtopics mobility midp questions jdb pine Deploying Applications on a Web Server 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 Change the JAD file s MIDlet Jar URL property to the URL of the JAR file The URL should be an absolute path For example MIDlet Jar URL http your server com midlets example jar 2 Ensure that the Web server uses the correct MIME types for JAD and JAR files a For MIDlet suite descriptors map the jad extension to the text vnd sun j2me app descriptor MIME type b For MIDlet suite JARs map the jar extension to the application java archive MIME type Chapter 2 Developing MIDlet Suites 7 2 6 The details of how to configure a Web server depend on the specific software used The emulator implements the device behavior during OTA provisioning You can use the emulator to test and demonstrate the full provisioning process of MIDlet suites from a server to the device All you need to do is launch the emulator s 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 opti
70. ication http jcp org en jsr detail id 172 Mobile 3D Graphics API for J2ME http jcp org en jsr detail id 184 J2ME Wireless Toolkit User s Guide October 2004 TABLE 1 Supported JCP APIs in the J2ME Wireless Toolkit JSR API Mobile Media API JSR 135 MMAPI 1 1 JSR 75 PIM and File JSR 82 Bluetooth and OBEX JSR 172 JSR 184 3D Graphics 4 CHAPTER 2 Developing MIDlet Suites This chapter describes how you can use the J2ME Wireless Toolkit to create applications It begins with a description of toolkit projects then works through the development process There are two basic development cycles you are likely to follow in creating MIDlet suite applications The first is quicker and simpler you will probably use it in your initial development The second cycle is longer but allows for more comprehensive and realistic testing Toward the end of the chapter you ll read about how to use the J2ME Wireless Toolkit with advanced development tools like an obfuscator and a debugger A final section briefly describes how to configure a web server to serve MIDP applications About Projects In the J2ME Wireless Toolkit MIDlet suites are organized into projects where the end result of one project is one MIDlet suite A project contains all of the files that will be used to build a MIDlet suite including Java source files resource files and the MIDlet descriptor The J2ME Wireless Toolkit works on one project
71. ication This is similar to Encryption and Authorization See RemoteDevice s authenticate method Chapter 11 Using the Bluetooth and OBEX APIs 5 11 3 2 11 3 3 11 3 4 76 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 1 2 Using Web Services The J2ME Wireless Toolkit emulator supports JSR 172 the JEME Web Services Specification JSR 172 provides APIs for accessing web services from J2ME applications It also includes an API for parsing XML documents The J2ME Wireless Toolkit provides a stub generator that automates creating source code for accessing web services To get to the stub generator choose File gt Utilities from the KToolbar menu Click on Stub Generator FIGURE 39 The web services stub generator Stub Generator Dialog x WSDL Filename or URL susr 72Demo srciserverscript wsdl Browse Output Path Browse Output Package feom jonathanknudsen CLDC Version f cLp 1 0 CLDC11 OK Cancel The WSDL Filename or URL should point to the WSDL file for the web service you want to access The Output Path indicates the location where you want the stub files to be placed Output Package indicates the Java language package name for the stub files Finally choose whether you want to generate CLDC 1 0 or CLDC 1 1 stubs Press OK to generate the stub files 77 78 J2ME Wireless Toolkit User s Guide October 2004 APPENDIX A Application
72. ill in a name The search is performed from the current selection in the call graph to the end If you want to search the entire call graph check Wrap before you click on the Find button As you click on different nodes in the call graph the right side of the profiler shows details about the methods for that node Execution Time and Number of Calls The right side of the profiler window displays detailed information about methods You can see the method name the number of times it was called and the amount of time that the emualtor spent in the method The execution time is described in four distinct ways Cycles shows the amount of processor time spent in the method itself Cycles is the percentage of the total execution time that is spent in the method itself Cycles with Children is the amount of time spent in the method and its called methods Cycles with Children shows the time spent in the method and its called methods as compared to the total execution time Click on any column to sort by that column Click a second time to switch the sort between ascending and descending The right pane shows the methods contained in the currently selected node in the call graph If you want to see every method click on the lt root gt node in the call graph Chapter5 Monitoring Applications 1 ILI 5 1 2 5 1 3 Saving and Loading Profiler Information To save your profiler session click on the Save butt
73. ing the J2ME Wireless Toolkit 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 Chapter 2 Developing MIDlet Suites 27 224 If you are following along with the example project create a new Java source file TinyMID1let java It should be saved in the source directory of your project which will be toolkit apps Tiny src TinyMIDlet java where toolkit is the installation directory of the toolkit The contents of the file are a very simple MIDlet import javax microedition lcdui import javax microedition midlet MIDlet public class TinyMIDlet extends MIDlet implements CommandListener public void startApp Display display Display getDisplay this Form mainForm new Form TinyMIDlet mainForm append Welcome to the world of MIDlets Command exitCommand new Command Exit Command EXIT 0 mainForm addCommand exitCommand mainForm setCommandListener this display setCurrent mainForm public void pauseApp public void destroyApp boolean unconditional public void commandAction Command c Displayable s if c getCommandType Command EXIT notifyDestroyed Save the file when you re finished Build The next step is to build your source code The toolkit makes this part very easy In the KToolbar window
74. ing your development time and the size of your MIDlet suite JAR Third Party Libraries for One Project Any library files placed in your project s 1ib directory will be included in the building and packaging of your project 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 WIK22 apps Tiny lib When you build run debug and package your project the class files in the 1ib directory are used Third Party Libraries for All Projects Some devices have libraries available to all installed MIDlet suites A manufacturer for example can make additional APIs available on all their devices In this case you want to be able to use these libraries when you build and test your application You don t want the libraries to be included in your packaged MIDlet suite because you will be installing the MIDlet suite on devices where the library is already present You can accomplish this by placing libraries in the toolkit apps 1lib directory For example if you installed the J2ME Wireless Toolkit in C WTK22 you would place the class libraries in C WTK22 apps 1ib Libraries in this directory are available for all projects 3 6 1 3 6 2 Configuring KToolbar KToolbar includes some advanced configuration options You can use these options by editing the toolkit wtklib platform ktools properti
75. k 6 Tempo Increases or decreases the tempo of the tone sequence or MIDI file Pitch Up Lowers or raises the notes in a MIDI file and down Start Stop Records the audio playback A file is created containing the Recording recorded audio in the directory in which the emulator is running If you do not specify a filename a file called recording wav is created This command toggles to Stop Recording Step Frame 7 Jumps forward or backward one frame at a time in a video file 9 Play Stop 2and Starts or stops the media Select Appendix A Application Demonstrations 9 TABLE10 Simple Player commands Command Key Description Loop Mode Plays back the audio file immediately after completion of play Running Loopmode once plays the audio file once Pressing a second time plays the file three times Pressing a third time plays the file repeatedly Pressing a fourth time returns to single play Skip land Skips forward or backward five percent of the duration of the 3 media file The sound track syncs to the video Rewind Returns to the start time of the audio playback Stop and 5 Stops plaback and rewinds to the start time Rewind Quick Help Displays a list of commands and keypad buttons The commands may or may not be available depending on the media type that Simple Player is playing In addition some commands can be invoked using the keypad buttons The following table describes the availability of commands their keypad
76. lasspath the toolkit uses for compiling and preverifying your source files J2ME Wireless Toolkit User s Guide October 2004 20 Changing MIDlet Suite Attributes The project settings window also allows you to control the MIDlet suite attributes which are stored in the descriptor as well as the manifest file of the MIDlet suite JAR To see the attributes run KToolbar and open a project Then click on Settings The three tabs that define attributes are Required Optional and User Defined 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 Once your application is stable and you re starting to think about deploying on real devices and going to market you should come back and adjust the values To adjust a value on the Required or Optional tabs click on the cell next to the attribute key you wish to change Type in the new value Chapter 3 Working With Projects 1 3 2 FIGURE 14 Editing MIDlet suite attributes 1 Settings for project Tiny a aay MiDlet Date Size SID MiDlet Delete Confirm MlDlet Description This is a verv tiny MIDlet suite To create new user defined attributes click on the User Defined tab Press Add and fill in the key name You can then edit the attribute val
77. led _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 B 5 3 112 J2ME Wireless Toolkit User s Guide October 2004 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 The syntax for the stub generator command is as follows wscompile options configuration_files Options for the wscompile Command Description specify where to place generated output files enable the given features same as f lt features gt generate debugging info same as gen client generate client artifacts stubs etc specify a HTTP proxy server port defaults to 8080 generate interfaces and value types only write the internal model to the given file optimize generated code specify where to place generated source files output messages about what the compiler is doing print version information Set the CLDC version to 1 0 default float and double become String Set the CLDC version to 1 1 float and double are ok Show all CLDC 1 0 info warning messages Appendix B Command Line Reference 113 Options TABLE 14 Option
78. lity for testing WMA applications The chapter concludes with a brief description of the network monitor s WMA support 7 1 Setting Emulator Phone Numbers Each running instance of the emulator has a simulated phone number that is shown in the title bar of the emulator window The phone numbers are important because they are used as addresses for WMA messages By default the first emulator instance has a phone number of 555000 Subsequent instances of the emulator will have unique numbers in ascending order 5550001 5550002 5550003 etc You can affect the assigned phone numbers by choosing Edit gt Preferences from the KToolbar menu and clicking on the WMA tab 57 FIGURE 29 Setting WMA preferences x Preferences for amp Network Configuration Performance Monitor Storage WMA Security BluetoothiOBEX Phone Number of Next Emulator 6269333 First Assigned Phone Number 5550000 Random Message Fragment Loss 0 0 20 40 60 80 100 Message Fragment Delivery Delay ms The changes will take effect the next time the emulator is executed OK Cancel The Phone Number of Next Emulator field is just what it sounds like If you fill in a number for this field the next emulator instance will have that number If the Phone Number of Next Emulator is already in use or if the field is blank then the First Assigned Phone Number is used for the next emulator in
79. ltor is running choose MIDlet gt External events from the emulator window s menu You ll see a utility window for adding and removing roots FIGURE 37 Managing filesystem roots 5550000 External Evje m File System Root Directories music Mount Nev Unmount The mounted roots and their contents are available to applications using the FileConnection API To add a new root directory click on Mount New and fill in a name for the directory To make a directory inaccessible to the FileConnection API select it in the list and click Unmount The PIM API The J2ME Wireless Toolkit emulator stores contact calendar and to do information in standard files on your desktop computer s hard disk All information is stored in toolkit appdb skin pim This directory is shared by all running emulators Lists are stored in subdirectories of the contacts events and todo directories For example a contact list called Contacts is contained in toolkit appdb skin pim contacts Contacts Inside the list directory items are stored in vCard or vCalendar format see http www imc org pdi Contacts are stored in vCard format while calendar and to do items are both stored in vCalendar format 10 2 72 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 1 1 Using the Bluetooth and OBEX APIs The J2ME Wireless Toolkit emulator supports JSR 82 the Java APIs for Bluetooth JSR 82 in
80. mory 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 gt Run via OTA The emulator window pops open but instead of running your MIDlet classes directly this time the emulator shows the welcome screen of its Application Management Software AMS The emulator s AMS is an example of the type of software that real devices must have to manage MIDlet suites FIGURE8 Emulator AMS welcome screen Java POWERED Choose Apps to go to the main list of installed applications Select Install Application and press the select button on the emulator The emulator prompts you for the URL location of the application you want to install The URL is already filled in for you 22 12 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 9 URL prompt http Mocalhost 2455 Tinybin Tiny html 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 FIGURE 10 Confirming the installation Are you sure you want to install Tiny Size 2K Version 1 0 Vendor Unknown Website Tiny jar Advanced Untrusted Choose Install again to finish the installation You ll be returned to the emulator s installed list of applications which
81. mount 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 The total amount of memory available at startup Remember you can modify the heap size using the Storage tab of the KToolbar preferences See Chapter 3 Working With Projects for details To request the system to perform a garbage collection click on Run GC Note The memory usage you observe with the emulator is not going to be exactly the same as memory usage on a real device Remember the emulator does not represent a real device It is just one possible implementation of its supported APIs To see details about the objects in your application click on the Objects tab in the memory monitor window FIGURE 23 The memory monitor objects display File Utilities View Open Session Graph Objects YM Internal java lang OutOfMemoryError java lang String java lang Thread char java io PrintStream com sun midp io SystemOutputStream java io OutputStreamivyriter java lang String java lang StringBuffer com sun cldc i18n ucle DefauttCasec java lang ClassNotFoundException intl com sun kvem clde i1 8n j2me Generic com sun midp main CommandState com sun midp security SecurityToken Objects 4090 Used 111448 bytes Free 388552 bytes Total
82. n A 9 SMS and CBS and MMS messages General Instructions It s usually very simple to run one of the demonstration applications This section describes the general procedure More detailed instructions for specific demonstrations are referenced in the table above The first step is to run KToolbar To do this go to the Windows Start menu and choose Start gt Programs gt J2ME Wireless Toolkit 2 2 gt KToolbar The KToolbar window pops up FIGURE 40 K Toolbar Bal J2ME Wireless Toolkit a ici xi File Edit Project Help New Project BE Open Project y settings IZ Clear Console Device DefaultColorPhone Create a new project or open an existing one Click on the Open Project button to open a demonstration application You ll see a list of all the available applications Appendix A Application Demonstrations 1 A 2 FIGURE 41 Opening a demonstration application project xi HE apps 7 6 Audiodemo 7 9 BluetoothDemo Demo3D 7 9 Demos FPDerno 7 9 Games JSR172Demo x Select one and click on the Open Project button in the dialog Once the application is opened all you need to do is press the Run button The device emulator will pop up running the example application Choose a specific demonstration to run from the menu and press the soft button for Launch Some demonstrations require other setup and instructions Check the full list to s
83. n either the connection string URL or content Datagram Comm When you are done entering filter settings press OK to return to the network monitor The Filter checkbox is checked indicating that a filter is in use To disable the filter and see all messages uncheck the checkbox Sorting Messages To arrange the message tree in a particular order click on the Sort By combo box and choose a criteria Time Messages are sorted in chronological order of time sent or received m URL Messages are sorted by URL address Multiple messages with the same address are sorted by time Connection Messages are sorted by communication connection Messages using the same connection are sorted by time This sort type enables you to see messages grouped by requests and their associated responses Sorting parameters are dependent on the message protocol you choose For instance sorting by time is not relevant for socket messages Saving and Loading Network Monitor Information To save your network monitor session choose File gt Save or File gt Save As from the network monitor window menu Choose a file name Sow 0 46 J2ME Wireless Toolkit User s Guide October 2004 To load a network monitor session choose File gt 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 Mes
84. n 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 MIDIlet 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 FIGURE 25 MIDlet suite permissions x API Selection Required Optional User Defined MiDiets Push Registry Permissions mMiDlet Permissions mt Settings for project Immediate3D javax microedition io Connector http javax microedition media control videoCortrol getSnapshot Remove MiDlet Permissions Opt javax microedition io Connector sms Add Remove To add a permission to either box click on Add and choose the permission you want to add To remove a permission highlight it and click on Remove Protection Domains The J2ME Wireless Toolkit includes four protection domains J2ME Wireless Toolkit User s Guide October 2004 MIDlets in the minimum domain are denied all permissions The untrusted domain provides a high level of security for applications whose origins and authenticity cannot be determined The user is prompted frequently when the application attempts a sensitive operation m The trusted domain is a happy place for MIDlets where all permissions are granted The maximum domain is equi
85. nd data exchange using Bluetooth Contains MIDlets that demonstrate how to use 3D graphics both immediate mode and retained mode Includes various examples animation color networking finance and others Simple floating point calculator Includes TilePuzzle WormGame and PushPuzzle Demonstrates how to use the JSR 172 API to connect to a web service from a MIDlet Demonstrates MMAPI features including tone sequences MIDI playback sampled audio playback and video Shows how to use datagrams and serial connections Demonstrates transferring data using OBEX over IrDA Shows how to manipulate contacts calendar items and to do items Demonstrates accessing local files APIs MMAPI 1 1 JSR 82 Bluetooth JSR 184 Mobile 3D Graphics MIDP 2 0 CLDC 1 1 MIDP 2 0 Web services MMAPI 1 1 MIDP 2 0 JSR 82 OBEX JSR 75 PIM and FileConnection J2ME Wireless Toolkit User s Guide October 2004 Application demonstrations Demonstration Audiodemo BluetoothDe mo Demo3D Demos FPDemo Games JSR172Demo mmademo NetworkDem 0 ObexDemo PDAPDemo TABLE 8 NEW NEW NEW NEW TABLE 8 Application demonstrations Special Demonstration APIs Description Instructions Photoalbum MIDP 2 0 Demonstrates a variety of image formats UIDemo MIDP 2 0 Showcases the breadth of MIDP 2 0 s user interface capabilities NEW WMADemo WMA 2 0 Shows how to send and receive Sectio
86. nd information that will be associated with the key pair 52 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 27 Creating a new key pair an New Key Pair 4 x Click on Create to generate a new key pair using the details listed below Alias respectable Subject Name Common Name Neal McScott Organization Unit Mobile Games 0000 7777 Organization Respectable Software Inc CityLocality Round Rock State Province rx Two Letter Country Code jus Cancel After you click on Create the toolkit prompts you to choose a protection domain The connection between the key pair you just created and a protection domain might seem oblique but it makes perfect sense The toolkit creates a self signed root certficate using the key pair you just created The root certificate is added to the emulator s list of root certificates The toolkit needs to associate the root certificate with a protection domain Now imagine what happens when you install a MIDlet suite signed with your new key The implementation examines the certificate chain in the MIDlet suite descriptor In this case the certificate chain is a single certificate the self signed root The implementation tries to find the root of the certificate chain in its internal list This succeeds because the root certificate was added when you create the key pair The implementation considers the certificate valid and us
87. ning using phone number 5550000 Console Sending a Text SMS Message To send a text SMS message click on Send SMS The send window pops up Chapter 7 Using the Wireless Messaging API a3 41 FIGURE 31 Sending a text message 0000 Send a Message SMS x Text SMS Binary sms To Selected Clients 5550002 Add Unlisted Client 5550000 5550001 Port Optional gt Message 11 he could think about was I m too young for this Clear Send Cancel The window automatically lists the phone numbers of all running emulator instances Select a destination Control click to select multiple destinations and enter a port number if you wish Type your message and click Send Sending a Binary SMS Message 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 2 60 J2ME Wireless Toolkit User s Guide October 2004 61 FIGURE 32 Sending a binary message TM 5550000 Send a Message SMS x Text SMS Binary SMS To Selected Clients Add Unlisted Client 5550000 6 33 5550001 Port Optional Send the contents of this file c Transtertrees mp3 Clear Browse Cancel 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
88. nterWrap 179 54075 2 768569 36 midp ReportHashtable getKeys 1 21670 01 649096 3 jutil Worker getTest 8 1240 6 640688 3 java Jang Class newinstance 7 637801 3 637801 3 imidp tests StackTest run 4 541 630320 29 java Jang String compareTo 946 627426 239 627426 29 imidp tests StackTest seekWMA 4 113 6 621421 29 javax microedition io Connector open 2 619130 29 619130 29 jcom sun midp icdui AutomatedEventHandler commandEvent 4 407455 139 606788 28 com sun midp icdui EmulEventHandler screenChangeE vert 3 293025 13 603370 28 mirin tests DisnlavTest run 4 AR ni ATARA 2 The profiler displays two types of information Method relationships are shown in a hierarchical list the Call Graph 40 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 The Call Graph The call graph shows a hierarchy of method calls Methods that call other methods are shown as folders Double click on a method to open it and see the methods it calls Methods that do not call any other method are shown as gray circles You can search for a particular class or method name Click on Find and f
89. o optimize network traffic To turn on the network monitor choose Edit gt 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 9 3 44 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 24 The network monitor AN Network Monitor 5550000 DefaultColorPhone Wireless Toolkit o x Fie Edit HTTP HTTPS sms 5 mms oBex 263 Socket sst Datagram Comm RL http slashdot org slashdot rdf GET meerkat _fl rss amp p 9 HTTP 1 Status Line HTTP 1 200 OK Body ime 2004 02 10 AD 16 51 06 EST 0197 ms C HTTP HTTP 1 200 OK E Body values 1 2 Chunk 0 connection close gt Chunk 1 ix bender They re tormenting me wit 2 Chunk 2 accept ranges bytes Chunk 3 date Tue 10 Feb 2004 21 49 0 HHTTP GET slashdot rdf HTTP 1 server Apaches 3 29 Unix mod Body content length 1930 HTTP 1 200 OK x powered by Slash 2 003000 vary Accept Encoding 1ae259 78a 40294965 Tue 10 Feb 2004 21 13 0 text xml I Fitter T Fiter Settnas Sort By Time Number of shown messages 4 out of 4 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 piece
90. ome overhead in addition to the space your application uses For example if you enter 8 kB for the persistent storage size 8192 bytes is available for both your application data and the storage overhead If you wish to erase the persistent storage of the emulator choose File gt Utilities from the KToolbar menu Click on the Clean Database button to wipe the persistent storage clean Adjusting Emulator Performance The emulator uses many of the resources of your desktop computer including its display and network connection Compared to the desktop based emulator a real 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 Choose Edit gt Preferences and click on the Performance tab 4 3 4 34 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 19 Adjusting the emulator s performance x Preferences for He Network Configuration Performance Monitor Storage wma Security Bluetoothosex Horror y Graphics primitives latency 0 milliseconds 0 20 40 Display refresh Double Buffer Immediate Periodic YO oy Ca a a
91. on in the profiler window Choose a file name To load a profiler session choose File gt Utilities from the KToolbar menu Click on Open Session in the Profiler box When you select a file the profiler window appears with all the session information 5 2 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 To turn on the memory monitor choose Edit gt Preferences from the KToolbar menu Click on the Monitor tab Check Enable Memory Monitor Next time you run the emulator the memory monitor window pops up displaying a graph of your application s memory usage over time The memory monitor slows down your application startup because every object created is recorded FIGURE 22 The memory monitor graph EG Memory Monitor Extension 5550000 DefaultColoxPhone Wireless Toolkit a lol x File Utilities Open Session Save Graph objects Current 103424 bytes Maximum 229276 bytes Objects 1526 Used 103424 bytes Free 158720 bytes Total 262144 bytes The memory monitor graph shows the following information Current The current amount of memory used by the application 42 J2ME Wireless Toolkit User s Guide October 2004 Maximum The maximum a
92. onality in a compact package that s appropriate for CLDC MIDP devices The API provides two methods for displaying 3D graphics content The immediate mode API makes it possible for applications to directly create and manipulate 3D elements Layered on top of this is a scene graph API also called retained mode that makes it possible to load and display entire 3D scenes that have been designed ahead of time Applications are free to use whichever approach is most appropriate or to use a combination of the retained mode and immediate mode APIs The JSR 184 specification also defines a file format m3g for scene graphs For more information consult the JSR 184 specification http jcp org en jsr detail id 184 JSR 184 provides a standard API for CLDC MIDP devices enabling a new generation of 3D applications The immediate mode API in turn is compatible with OpenGL ES a standard lightweight API for 3D graphics See http khronos org for more information on OpenGL ES 9 1 Immediate Mode Immediate mode is appropriate for applications that generate 3D graphics content algorithmically like scientific visualizations or statistical graphs The application creates 3D objects and manipulates them directly 67 9 2 For an example of immediate mode see the Life3D MIDlet in the Demo3D example application Retained Mode Most applications particularly games will use the retained mode or scene graph API In this approach
93. one Number Value integer WMA gt Random Message Fragment Loss Value integer WMA gt Message Fragment Delivery Delay ms Value integer Using Security Features TABLE 13 Emulator Preferences Properties List Property Name mm control mixing mm control record mm control volume mm format midi mm format video mm format wav wma client phoneNumber wma server firstAssignedPhoneNumber wma server percentFragmentLoss wma server deliveryDelayMS 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 Changing the Emulator s Default Protection sign MIDlet suites and manage certificates Domain To adjust the emulator s default protection domain use the following option with the emulator command Xdomain lt domain_type gt Assigns a security domain to the MIDlet suite Domain types include untrusted trusted minimum and maximum J2ME Wireless Toolkit User s Guide October 2004 B 5 B 5 1 110 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 JadTool only uses certificates and keys from J2SE keystores J2SE provides keytool
94. ons In the Windows start menu choose Start gt Programs gt J2ME Wireless Toolkit 2 2 gt OTA Provisioning From the command line run toolkit bin emulator Xjam Now follow the AMS prompts to install your application This process is very similar to the Run via OTA option described earlier in this chapter except you will need to enter the URL of your own server to install your application J2ME Wireless Toolkit User s Guide October 2004 18 CHAPTER 3 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 m Selecting the target APIs for a project Manipulating MIDlet suite attributes including the list of MIDlets Understanding the project directory structure Including third party libraries in a project Selecting APIs Each project is built against some set of APIs The J2ME Wireless Toolkit supports many APIs the full list is detailed in Chapter 1 Introduction The toolkit allows you to develop applications for some subset of APIs based on the type of devices you expect to run your software For example even though the toolkit supports JSR 184 the Mobile 3D Graphics API you might want to develop applications that don t make use of that API The project s API Selection settings make it possible to choose only
95. oose the Default Device Selection item and choose one of the available emulator skins Next time you launch the emulator the selected skin is used You can also run the emulator from a command prompt See Appendix B Command Line Reference for more information 4 5 Using Third Party Emulators Third party companies like device manufacturers and wireless carriers sometimes create device emulators that are compatible with the J2ME Wireless Toolkit You can gain experience running your application on a wider variety of implementations by installing additional emulators into the toolkit The procedure 4 6 36 J2ME Wireless Toolkit User s Guide October 2004 is usually to unpack install the third party emulator then copy its directory into the lt toolkit gt 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 Using the Emulator 7 38 J2ME Wireless Toolkit User s Guide October 2004 CHAPTER 5 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 The memory monitor shows the usage of m
96. ows an animated GIF as a Form Item The form also includes some information about the playback including the current time Choose the Snapshot command to take a snapshot of the running animation The snapshot will be placed in the form following the animated GIF m Animated GIF Canvas jar shows an animated GIF in a Canvas A simple indicator shows the progress through the animation Choose Snapshot to get a still image of the current appearance The snapshot is shown briefly then the display goes back to the animation Video Capture Form simulates capturing video from a camera or other source and showing it as an Item in a Form Choose the Snapshot command to take a snapshot of the captured video The snapshot will be placed in the form following the video capture Video Capture Canvas simulates capturing video from a camera or other source and showing it in a Canvas Choose Snapshot to get a still image of the current appearance The snapshot is shown briefly then the display goes back to the video capture Attributes for mmademo The mmademo applications have the following attributes that you can modify in the User Defined tab of the project settings dialog box TABLE 11 Descriptions of MMAPI specific MIDlet attributes Attribute Description PlayerTitle lt m gt Name of the nth media title to be played back by the Simple Player MIDlet PlayerURL lt n gt Location of the nth media title PLlayerTitle lt n gt to be
97. played back by the Simple Player MIDlet 1 660165 gt 7 lt The name of the nth media title to be played back by the Video application VideoTest Location of the nth media title VideoTest lt n gt to be played URL lt n gt back by the Video application A 6 5 ObexDemo This application shows how to transfer image files between emulator instances using the OBEX API This demonstration shows the use of OBEX over a simulated infrared connection Appendix A Application Demonstrations 91 A 7 Run two instances of the emulator One listens for incoming connections while the other attempts to send an image In the first emulator choose Obex Demo then Receive Image The emulator will ask for permission to listen Choose Yes The emulator will display a screen that indicates it s waiting for incoming connections FIGURE 47 Waiting for an OBEX connection Waiting for connection In the second emulator launch Obex Demo then choose Send Image You ll see a list of images 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 92 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 48 Prompting to accept a connection ame Jimagesjeat png ength 51979 ould you like to receive it Choose Yes The image you selected is tr
98. pplication While you re developing your application the toolkit s certificate management utility provides a convenient way to manipulate the emulator s list of root certificates for testing purposes Choose File gt Utilities from the KToolbar menu Click on the Manage Certificates button to open up the certificate manager window FIGURE 28 The certificate manager FA J2ME Certificate Manager _main ks a loj xj File Action Open Keystore Import Certificate J2ME Key Details Owner O Respectable Software Inc C respectal Valid from Thu Mar 18 12 26 23 EST 2004 to Wet Security Domain trusted_operator C US 0 GeoTrust Inc CN GeoTrust Global C C US O GTE Corporation OU GTE CyberTrust C US O GTE Corporation CN GTE CyberTrust C US O GTE Corporation OU GTE CyberTrust C ZA ST Vestern Cape L Cape Town O The C Z4 ST Western Cape L Cape Town O The C ZA ST Vestern Cape L Cape Town O Th C Z4 ST Western Cape L Cape Town O The C ZA4 ST Western Cape L Cape Town O The C US 0 VeriSign Inc OU Class 1 Public Prim C US 0 VeriSign Inc OU Class 2 Public Primi C US 0 YeriSign Inc OU Class 3 Public Prim C US 0 VeriSign Inc OU Class 4 Public Primi C US O RSA Data Security Inc OU Secure Each certificate is shown as a single line in the left part of the window the Certificate List When you click on a certificate its details are shown in the right part of the window You ll also see the certificat
99. rd Party Libraries for All Projects 6 3 7 Configuring KToolbar 26 3 7 1 Setting the Application Directory 27 3 7 2 Setting the javac Encoding Property 27 3 7 3 Working with Revision Control Systems 7 4 Using the Emulator 29 4 1 Emulator Skins 9 4 2 Using the Emulator 0 4 3 Setting Emulator Preferences 2 4 3 1 Network Proxies 32 4 3 2 Heap Size 33 4 3 3 Storage and Cleaning 33 4 3 4 Adjusting Emulator Performance 34 4 4 Pausing and Resuming 35 4 5 Running the Emulator Solo 6 4 6 Using Third Party Emulators 36 5 Monitoring Applications 39 5 1 Using the Profiler 9 5 1 1 The Call Graph 41 5 1 2 Execution Time and Number of Calls 1 5 1 3 Saving and Loading Profiler Information 1 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 5 3 1 Filtering Messages 45 5 3 2 Sorting Messages 46 5 3 3 Saving and Loading Network Monitor Information 6 5 3 4 Clearing the Message Tree 47 6 Security and MIDlet Signing 9 6 1 Permissions 49 6 2 Protection Domains 0 6 3 Signing a MIDlet Suite 1 6 4 Managing Keys 52 6 4 1 Creating a New Key Pair 52 6 4 2 Getting Real Keys 53 6 4 3 Importing an Existing Key Pair 54 6 4 4 Removing a Key Pair 54 6 5 Managing Certificates 54 6 5 1 Importing Certificates 5 6 5 2 Removing Certificates 56 7 Using the Wireless Messaging API 7 7 1 Setting Emulator Phone Numbers 7
100. runtime debugging The Xrunjdwp option must also be used Xrunjdwp lt debug_settings gt Start a JDWP debug session as specified by a list of comma separated debug settings The Xdebug option must also be used Valid debug settings include transport lt transport_mechanism gt The transport mechanism used to communicate with the debugger The only transport mechanism supported is dt_socket address lt host port gt The transport address for the debugger connection You can omit providing a host If host is omitted localhost is assumed to be the host machine server y n Start the debug agent as a server The debugger must connect to the port specified The possible values are y and n Currently only y is supported the emulator must act as a server Appendix Command Line Reference 107 B 3 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 TABLE 12 Toolkit component commands Command Description DefaultDevice Pops up a dialog that allows you to choose the default emulator skin ktoolbar Launches KToolbar prefs Launches the toolkit preferences utils Launches the toolkit utilities window B 4 Setting Emulator Preferences You can change the emulator preferences from the command line by using the Xprefs option for the emulator command The format is as follows Xprefs lt filen
101. s Click on a message or a portion of a message to see details in the right side of the network monitor Message bodies are shown as raw hexadecimal values and the equivalent text Note You can examine messages that are still in the process of being sent Incomplete messages are indicated by bold highlighting in the message tree Filtering Messages Filters are useful for examining some subset of the total network traffic Filter settings are specific to the network protocol used Chapter 5 Monitoring Applications 5 Sal Press the Filter Settings button to use the filter Change the filter settings to suit your needs TABLE 5 Network monitor filter settings Network Protocol Filter Settings HTTP HTTPS Enter text to match the various parts of HTTP messages URL status line headers or body For example entering slashdot in the URL field would filter to show only messages whose URL contained slashdot SMS CBS You can specify a protocol message type and direction to match Furthermore you can enter text to match in the sender receiver and message content MMS Enter text to match the direction sender receiver and copied cc and blind copied bcc receivers In addition you can filter on the subject content ID content location MIME type and encoding OBEX SPP L2CAP You can filter using the URL or header content Socket SSL Enter text to match i
102. s the source code preverifies the class files and packages a MIDlet suite Running and monitoring You can run a MIDlet suite directly in the emulator or install it using a process that resembles application installation on a real device A memory monitor network monitor and method profiler are provided to analyze the operation of your MIDlets MIDlet suite signing The toolkit contains tools for cryptographically signing MIDlet suites This is useful for testing the operation of MIDlets in different protection domains 1 3 Supported Technology The J2ME Wireless Toolkit supports many standard Application Programming Interfaces APIs defined through the Java Community Process JCP TABLE 1 shows the APIs and includes links to the specifications TABLE 1 Supported JCP APIs in the J2ME Wireless Toolkit JSR Name API URL JSR 139 Connected Limited Device Configuration CLDC 1 1 http jcp org en jsr detail id 139 JSR 118 Mobile Information Device Profile MIDP 2 0 http jcp org en jsr detail id 118 JSR 185 Java Technology for the Wireless Industry JTWI 1 0 http jcp org en jsr detail id 185 JSR 205 Wireless Messaging API WMA 2 0 http jcp org en jsr detail id 205 Chapter 1 Introduction 1 4 Name URL http jcp org en jsr detail id 135 PDA Optional Packages for the J2ME Platform http jcp org en jsr detail id 75 Java APIs for Bluetooth http jcp org en jsr detail id 82 J2ME Web Services Specif
103. sage Tree To remove all messages from the network monitor choose Edit gt Clear from the network monitor menu Chapter 5 Monitoring Applications 7 48 J2ME Wireless Toolkit User s Guide October 2004 Security and MIDlet Signing MIDP 2 0 includes a comprehensive security model based on protection domains MIDlet suites are installed into a protection domain which determines access to protected functions The MIDP 2 0 specification also includes a recommended practice for using public key cryptography to verify and authenticate 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 permissions If you need more background on public key cryptography try this article MIDP Application Security 1 Design Concerns and Cryptography http developers sun com techtopics mobility midp articles securityl This chapter describes support for protection domains permissions and MIDlet signing in the J2ME Wireless Toolkit CHAPTER 6 Permissions MIDlets must have permission to perform sensitive operations like connecting to the network Permissions have specific names and MIDlet suites can indicate their need for certain kinds of permissions through attributes in the MIDlet suite descriptor 49 6 1 I
104. ssage To resume the MIDlet s operation choose MIDlet gt Resume from the menu Running the Emulator Solo During development you will most often run the emulator directly from KToolbar by pressing the Run button or using the Project gt 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 To run an application directly which is analagous to pressing KToolbar s Run button choose the Run MIDP Application item The toolkit prompts you to locate a MIDlet descriptor file on your local disk Note that the corresponding MIDlet suite JAR must also be present To run the emulator s Application Management Software AMS choose the OTA Provisioning item which is roughly analagous to KToolbar s Run via OTA feature The emulator pops up with the AMS welcome screen and you can install applications by typing in a URL To change the emulator s preferences choose the Preferences item from the toolkit program group This pulls up the same preferences window as choosing Edit gt Preferences from the KToolbar menu The J2ME Wireless Toolkit utilities are also accessible without running KToolbar Just choose the Utilities item Finally you can change which emulator skin is used by default Ch
105. stance Subsequent instances count up For example suppose you fill in 6269333 for the Phone Number of Next Emulator and 5550000 for the First Assigned Phone Number If you launch four emulator instances their numbers will be 6269333 5550000 5550001 and 5550002 Simulating an Unreliable Network Long messages are sent by splitting them up sending the fragments separately and reassembling the fragments on the receiving end You can simulate some of the hazards of the wireless network in the J2ME Wireless Toolkit As before choose Edit gt Preferences from the KToolbar menu and click on the WMA tab If like the toolkit to lose some message fragments adjust the Random Message Fragment Loss slider to the desired percentage If you would like to simulate a delay between the time message fragments are sent and received enter the delay in milliseconds in the Message Fragment Delivery Delay field 7 2 58 J2ME Wireless Toolkit User s Guide October 2004 59 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 gt Utilities from the KToolbar menu Click on Open Console in the WMA box FIGURE 30 The WMA console 1O x 2 5550000 WMA Console Send CBS Send MMS Console run
106. ste de personnes qui font objet d un ordre de ne pas participer d une facon directe ou indirecte aux exportations des produits ou des services qui sont regi par la legislation americaine en matiere de controle des exportations et la liste de ressortissants specifiquement designes sont rigoureusement interdites LA DOCUMENTATION EST FOURNIE EN L ETAT ET TOUTES AUTRES CONDITIONS DECLARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE Y COMPRIS NOTAMMENT TOUTE GARANTIE IMPLICITE RELATIVE A LA QUALITE MARCHANDE A L APTITUDE A UNE UTILISATION PARTICULIERE OU A L ABSENCE DE CONTREFACON OY Se a Adobe PostScript Ley 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 2 3 The Full Development Cycle 11 2 3 1 Package 11 2 3 2 Install 2 2 3 3 Run 14 2 4 Using an Obfuscator 15 2 5 Usinga Debugger 17 2 6 Deploying Applications on a Web Server 17 3 Working With Projects 19 Contents iii 3 1 Selecting APIs 19 3 2 Changing MIDlet Suite Attributes 1 3 3 Manipulating MIDlets 23 3 4 Using the Push Registry 24 3 5 Project Directory Structure 25 3 6 Using Third Party Libraries 25 3 6 1 Third Party Libraries for One Project 26 3 6 2 Thi
107. t your application under different resource conditions Network Proxies The emulator uses your desktop network connection For example if the emulator runs a MIDlet that makes an HTTP connection the emulator attempts to make the HTTP connection using the desktop s network setup If your development computer is behind a firewall you might use a proxy server to make HTTP connections If you re not sure try examining your browser s settings to see if it uses proxy servers If you are using proxy servers you need to configure the emulator to use the same proxy servers To do this choose Edit gt Preferences On the Network 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 4 3 4 3 1 32 J2ME Wireless Toolkit User s Guide October 2004 Heap Size The heap is memory where your application s objects are stored Many real devices have limited heap size You can set a maximum heap size to more closely simulate the conditions on a real device Choose Edit gt Preferences from the KToolbar menu and selecting the Storage tab Fill in the maximum heap size in the Heap Size field Remember one kilobyte kB is 1024 bytes If you don t specify a heap size the default is 2 megabytes FIGURE 18 The storage tab of the KToolbar preferences x Preferences for cS Network Configuration Performance Monitor
108. the development features it provides Chapter 2 describes the development processes for creating and running MIDlets Chapter 3 explains how to work with projects in KToolbar You ll learn how to adjust project properties manipulate MIDlets work with the push registry and understand the project directory structure Chapter 4 describes the emulator and explains how to adjust its options and take advantage of its many features Chapter 5 shows how you can examine the performance of your application using the method profiler memory monitor and network monitor Chapter 6 describes how to sign MIDlet suites and manage keys and certificates J2ME Wireless Toolkit User s Guide October 2004 x Chapter 7 details support for running and testing wireless messaging applications Chapter 8 explains how the J2ME Wireless Toolkit supports the Mobile Media API Chapter 9 contains information about developing 3D graphics content Chapter 10 describes how the toolkit implements access to local files and personal information like contacts and calendar appointments Chapter 11 covers the toolkit s Bluetooth and OBEX simulation environment Chapter 12 shows how to use the web services stub generator Chapter 12 shows how to use the web services stub generator 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
109. 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 6 7 FIGURE 4 File locations in the console Bal JIME Wireless Toolkit Tiny O x File Edit Project Help New Project amp Open Project amp Settings e Build p Run Clear Console z Device DefaultColorPhone Creating project Tiny Place Java source files in C WTK22 apps Tiny src Place application resource files in C WTK22 apps Tiny res Place application library files in C WTK22 apps Tiny lib settings updated Project settings saved The Simple Development Cycle The simple development cycle looks like this Edit source code gt Build Run 1 Edit source code In this step you create Java source files and resource files that will be used by your application 2 Build The J2ME Wireless Toolkit compiles and preverifies your Java source files 3 Run The compiled Java class files are run on the emulator If an error occurs when the toolkit attempts to compile your source files go back and edit them again If you find a bug when you are testing your application in the emulator edit the source files to fix the bug Now that you understand the simple development cycle at a high level the rest of this section illustrates how you can accomplish each step us
110. trations The actual files are located in toolkit appdb DefaultColorPhone filesystem assuming you are using the DefaultColorPhone emulator skin You can add files and root directories as you wish and they will be visible to the JSR 75 File API See Chapter 10 for more information The PIM API The JSR75 PIM APIs example demonstrates how to access personal information like contact lists calendars and to do lists After you launch the example choose a type of list from the main menu In this example application each type of list works the same way and each list type contains a single list For example if you choose Contact Lists there is a single contact list called Contacts Event Lists contains a single list called Events and To Do Lists conatains a single list called To do FIGURE 53 Choosing a list type 0000000000 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 A 8 2 96 J2ME Wireless Toolkit User s Guide October 2004 FIGURE 54 An empty contact list 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 FIGURE55 Adding contact fields E Mail jonathan knudsen sun coi
111. u can now use your own private key to sign MIDlet suites The J2ME Wireless Toolkit will take care of the details of placing the signature and your certificate into the MIDlet suite 6 4 3 Importing an Existing Key Pair You may have keys in a J2SE keystore that you would like to use for MIDlet signing In this case you need to import your signing keys to the J2ME Wireless Toolkit so that you can sign your MIDlet suite To do this from the MIDlet signing window click on Import Key Pair Select a file that contains a J2SE keystore You will be prompted for the keystore passphrase Then select the alias for the key pair you wish to import Finally you will need to select a protection domain for the key pair s root certificate 6 4 4 Removing a Key Pair To remove a key pair from the MIDlet signing window select its alias and choose Action gt Delete Selection 6 5 Managing Certificates You ve already heard about the emulator s list of root certificates In this section you ll learn how you can manage this list using the J2ME Wireless Toolkit 54 J2ME Wireless Toolkit User s Guide October 2004 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 Otherwise the device will be unable to verify your a
112. udes two independent APIs The FileConnection optional package allows MIDlets access to a local device file system The Personal Information Management PIM optional package includes APIs for manipulating contact lists address book calendars and to do lists This chapter describes how the J2ME Wireless Toolkit implements the FileConnection and PIM APIs The FileConnection API On a real device the Fi leConnection API typically provides access to files stored in the device s memory or on a memory card In the J2ME Wireless Toolkit emulator the FileConnection API allows MIDlets to access files stored on your desktop computer s hard disk The files that can be accessed using FileConnection are stored in subdirectories of toolkit appdb skin filesystem For example the DefaultColorPhone emulator skin comes with a root directory installed called root which contains a file called Readme The full path of the file is 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 toolkit appdb DefaultColorPhone 1089982856218 filesystem 71 10 1 Each subdirectory of filesystem is called a root The 21 15 Wireless Toolkit provides a mechanism for managing roots While the emua
113. ue 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 22 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 1121665 tab You will see a list of all MIDlets in the project If you just created a new project the toolkit automatically fills in the first MIDlet entry FIGURE 15 The list of MIDlets in a project wt Settings for project Tiny Push Registry Permissions _ Key Nome ton ass Mitt Tiny Tiny png gt Mave Wp Mave Dow Remove To add a new MIDlet click on Add Fill in the name icon file name and class name You can leave the icon file name blank if you wish To change values or remove MIDlet entries use the Edit and Remove buttons Chapter 3 Working With Projects 23 0 The MIDlet names are presented to the user in the order shown when the MIDlet suite is launched You can modify the order by selecting a MIDlet and clicking Move Up or Move Down 3 4 Using the Push Registry You can also use project settings to work with a MIDlet suite s push registry settings Click on Settings
114. valent to trusted When you press the Run button to run your application in the emulator your code runs in the untrusted protection domain by default You can change which protection domain is used by choosing Edit gt Preferences from the KToolbar menu Select the Security tab You can now choose the default protection domain from the combo box Things are different when you use Run via OTA Your packaged MIDlet suite is installed directly into the emulator and it is placed in a protection domain at installation time The emulator uses public key cryptography to determine the protection domain of installed MIDlet suites If the MIDlet suite is not signed it is placed in the unt rusted domain If the MIDlet is signed it is placed in whatever protection domain is associated with the root certificate of the signing key s certificate chain For example suppose Respectable Software a hypothetical company wants to distribute a cryptographically signed MIDlet suite Respectable Software buys a signing key pair from Super Trustee a hyptothetical certificate authority Using the signing key Respectable Software signs the MIDlet suite and distributes their certificate with the MIDlet suite When the MIDlet suite is installed on the emulator or on a device the implementation verifies Respectable s certificate using its own copy of Super Trustee s root certificate Then it uses Respectable s certificate to verify the signature on the M
115. ve a part select it and press Remove FIGURE 35 Adding parts to an MMS message TM 5550000 Send a Message MMS CATranster kri kristen jpg 800 2 Chapter 7 Using the Wireless Messaging API 7 4 Receiving Messages in the WMA Console The WMA console can also receive messages If you look at the WMA console window you ll see it has its own phone number in the title bar You can send messages to the WMA console from your applications running on the emulator Received messages are shown in the WMA console s text area 7 5 Using the Network Monitor with WMA The network monitor was fully described in Chapter 5 Monitoring Applications You can use the network monitor to track WMA messages that are sent to or from the emulator Click on the SMS CBS or MMS tabs to see WMA messages Information about the messages and their fragments is shown in the left pane of the network monitor Click on a message or message fragment to see its details in the right pane FIGURE 36 Using the network monitor to view a WMA message QM Network Monitor 5550001 DefaultColorPhone Wireless Toolkit x File Edit HTTP HTTPS SMS 05 mms OBEX 200 Socket SsL Datagram Comm r IRL sms 5550000 50000 H SMS gt sms 5550000 50000 ize 63 B y Fragment ama pajama rolled out of bed and she ran to the police station 0 4d 61 6d 61 20 70 61 68 61 6d

Download Pdf Manuals

image

Related Search

Related Contents

Philips DLA1209  Esenciales Diarios  “P0 Installation manual Model: SUZUKI Grand Vitara Skid plate for  Zanussi ZDF 222 User's Manual  取扱説明書  SERVICE MANUAL - Appliance Factory Parts  パンフレット  Xerox® WorkCentre 3550 Guía de administración del sistema  Tripp Lite 1.44kW Single-Phase Hot-Swap PDU, 120V 15A Outlets (8 5-15R), 2 5-15P, 10ft & 6ft Cords 2U Rack-Mount  Zotac ZT-40703-10L NVIDIA GeForce GT 440 1GB graphics card  

Copyright © All rights reserved.
Failed to retrieve file