Programming Java 2 Micro Edition for Symbian OS 2004 (779882), страница 19
Текст из файла (страница 19)
A sub menu prompting the developer to locate the MIDP suite willappear (Figure 2.24). Press the Install button and the MIDlet willbe installed.3. It will appear as an icon on the emulator’s desktop. In this casewe have installed our Helloworld application from Section 2.2(Figure 2.25).InstallationThe SDK can be downloaded from the Symbian Developer Network atwww.symbian.com/developer/sdks uiq21.asp.1.
This download is delivered in the form of a ZIP file which needs tobe extracted to a suitable temporary location.78GETTING STARTEDFigure 2.23UIQ emulator.Figure 2.24 Install MIDlet.2.Navigate to the extracted files and execute Setup.exe. The installation process will begin.3.After accepting terms, conditions and the license agreement, a promptfor the destination of the SDK is given (Figure 2.26).4.Once this has been selected, you will be prompted to select thecomponents you wish to install (Figure 2.27). The rather greedysystem requirement for disk space (Figure 2.26) can be ignored.
Itrefers to the full Symbian ‘‘DevKit’’, which includes the full sourcecode. The example installation was installed on a PC with modestavailable disk space. A figure of approximately 550 MB, dependingupon the packages, example and documentation selected, is moreaccurate. As well as the packages forming the SDK itself, Perl and aJava Runtime are required. (This refers to the full Java Runtime Edition(JRE) version 1.3.1 and should not be confused with the MIDP 2.0runtime.) If these are not present on the target PC, then select themas well.
In this case it has been decided not to install them.5.After a summary dialog, an installer kit is installed. This is the firststage of the installation. If Perl, which is required to run the emulator,INTRODUCTION TO TOOLS FOR MIDP79Figure 2.25 Helloworld.and the Java Runtime have been selected, they will also be installedat this stage. This part can take some time.6. The installer is now ready to install the required SDK packages(Figure 2.28).7.
The developer should now decide which packages to install.Figure 2.29 demonstrates how the developer can pick and choosewhat they want to be installed on the PC. In this case, weare only interested in the emulator, the MIDP package and thedocumentation, which might help us better understand the SDK.Note that UIQ 2.1 Java SDK has not been selected. This is, in fact, forPersonalJava and therefore we are not interested in installing it in thisinstance.8. The installer gathers the packages together and displays the namesof all the selected packages and the required disk space.
Press Nextto continue. Before installing, a prompt appears asking the user toaccept the terms of the license. The SDK will then be installed. Onceit has been successfully installed, Figure 2.30 appears.80GETTING STARTEDFigure 2.26 Symbian OS Kit Installer.Figure 2.27 Install components.INTRODUCTION TO TOOLS FOR MIDP81Figure 2.28 Ready to install SDK.Figure 2.29Choosing packages.2.3.3.2 Sony Ericsson P900 J2ME SDKAlso available for UIQ developers is a Sony Ericsson MIDP 2.0 emulatorthat can be plugged into the Wireless Toolkit, version 2.1. This is avery useful tool for perfecting the user interface side of applicationdevelopment.
However, the drawback is that the Java runtime is Sun’sreference implementation, rather than the actual Symbian OS device82GETTING STARTEDFigure 2.30Installation complete.implementation, which can be found within the UIQ SDK described inSection 2.3.3.1. The Symbian emulator device is based upon Symbian’ssource code and more evenly reflects the real device, where the binariesare optimized for the ARM processor rather than the x86.The installation of the P900 emulator (Figure 2.31) for the WirelessToolkit is fairly straightforward. The required files can be downloaded fromthe Sony Ericsson developer portal at: www.sonyericsson.com/developer/user/ViewDocument.jsp?id=65090&name=java midp2 p900.zip.All the emulator devices for the toolkit are stored in the directory<installation location>\wtklib\devices\<emulatorname>. Once the ZIP file has been obtained, the files within thearchive can be extracted to SonyEricsson_P900, a subdirectory underdevice.
When the toolkit is next executed the new P900 device emulatorwill be available for selection.2.4 Installing and Running a MIDletNow that we have created our first MIDP 2.0 application and tested itwith the various emulators and toolkits described above, it is time totry it out on a real device. There are a number of ways to install theMIDlet suite. All have their own merits and conveniences. However, thedeveloper shouldn’t be reliant upon just one method.During development, from time to time, you should try out a test runon the target device, rather than relying on the emulators. The latter mayINSTALLING AND RUNNING A MIDLETFigure 2.3183P900 Emulator.not provide a true indication of application performance and usability.Emulator speeds can vary from the real devices and memory managementmay not be the same either.
During development, Bluetooth or infrareddeployment should be used. These are the easiest forms of installationand avoid the costs of installing the application over the air.2.4.1 Transferring the MIDlet to a Device2.4.1.1 Infrared InstallationOn the device, in this case the Nokia 6600, locate the Connect menu andthen the infrared command. Press Options > Open. This will activate theinfrared functionality. Put the device in line with and within range of alaptop with an infrared port, or a PC with an infrared pod. The laptop84GETTING STARTEDwill recognize that another computer is nearby.
In this case, the ‘‘nearbycomputer’’ is in fact the Nokia 6600.Navigate to the MIDlet JAR file and engage the shortcut menu. SelectSend to > nearby computer. Assuming the mobile device is within range,the JAR file will be sent to the device. When the phone has received theJAR file, it will appear as if a message has arrived on the device. When thedeveloper tries to open the message, the application manager softwaretakes over and installs the MIDlet on the device. This installation processcan be seen in more detail below.2.4.1.2 BluetoothThere are many Bluetooth accessories that can be added to laptopsand desktops. In this case, we used a Smart Modular Technologies USBAdaptor and connected it to a laptop.Assuming the software has been installed, the laptop has the ability tobrowse for other Bluetooth devices within its range. Transferring the fileto the mobile phone is simple. The Smart software allows the developerto browse for and select the appropriate JAR file.
The Bluetooth softwaresearches for and compiles a list of available devices. When the Nokia6600 realizes that it has been contacted, it prompts the user to givepermission to accept contact. In return, the mobile device passes apassword back to the laptop which has to be entered correctly beforethe conversation can continue. After validation, the JAR file is sent to theNokia device.
The JAR file arrives as a message and can be installed asdemonstrated below.The great advantage of this is that the laptop and the phone can beanywhere within 10 meters of each other and the connection is persistent,saving time for the developer.2.4.1.3 Over the AirCompared to the two methods described above, installing over the air(OTA) is a cumbersome way of installing an application on a deviceduring development. However, it is an important mechanism for distributing finished MIDlets and should therefore be tested rigorously priorto distribution.Whereas the infrared and Bluetooth methods do not require a JAD fileto install, the OTA method does. The JAD file specification is part of theMIDP 2.0 specification and forms an extra layer of security between thedevice and the application. It provides information to the device as towhat it is about to receive. The specification requires the information inthe JAD file to be very precise and, if it is not, the MIDlet installation willbe unsuccessful.
It is therefore very important to test installation by thismethod to ensure the end-user can install and purchase the application.It is, after all, convenient for the user and is a way to maximize revenueINSTALLING AND RUNNING A MIDLET85streams if the application has been distributed to content providers andnetwork operators to good effect.To facilitate this, the developer will need to create the JAD file asdescribed in Section 2.1.1.6.