Programming java 2 micro edition for symbian os phần 3 pdf

50 311 0
Programming java 2 micro edition for symbian os phần 3 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

72 GETTING STARTED 2.3.2.3 Sun ONE Studio 4, Mobile Edition Overview Sun ONE Studio 4 is widely used within the Java developer community. This IDE gives the developer all the usual source file editing, packaging, pre-verification and compilation processes. The Wireless Toolkit has been integrated with the IDE. It also comes with plenty of examples to get the developer started, both with the IDE and with MIDP development. There is a free offering of the IDE from the Sun Java website at the fol- lowing location: http://wwws.sun.com/software/sundev/jde/studio me/ index.html ). The free version can be used for non-commercial evaluation purposes. In the same way that JBuilder 9 can be integrated with the Nokia Developer’s Suite, so can this IDE. The text editor offers code completion and contextual shortcut menus to save the developer having to search for commands. A project navigator is also available, as is version control through its ”VCS groups” and CVS functions. While this book will be examining version 4 of the software, it should be noted that at the time of writing an early access edition of version 5.0 was being released. While this is not a full production release it is worth noting that it has the following features: • J2ME Wireless Toolkit integration • dual support for both J2ME MIDP 1.0 and 2.0 development • MIDP 2.0 development features • application signing utility to sign MIDlet suites • Push Registry development • over-the-air (OTA) testing • J2ME Wireless Toolkit Project Import Wizard • Wireless Connection Wizard for development of networked J2ME applications • integration of third-party device SDKs through the emulator registry • XML-file-based emulator configuration and integration • sample MIDlets to get the developer started. Installation The IDE will run on the following systems: • Solaris 8 and 9 operating environments • Windows XP, NT 4.0 SP6, 2000 SP2, 98 (Community Edition only) • Red Hat Linux 7.2 and Sun Linux 5.0 INTRODUCTION TO TOOLS FOR MIDP 73 As a runtime environment, it requires J2SE at version 1.3.1, 1.4.0, or 1.4.1. It will compile code developed with JDK 1.0 or 1.1, or J2SE 1.2, 1.3, 1.3.1, 1.4.0, or 1.4.1. The installation package can be obtained from the following location: http://wwws.sun.com/software/sundev/jde/studio me/index.html . 1. To begin the installation process, execute the file ffj_me_win32. exe. A welcome dialog is displayed to the user (Figure 2.18). 2. When the user accepts the terms and condition of using the software, a search for a suitable Java Virtual Machine starts. If one can be found then accept it, otherwise its location, if present on the PC, should be given to the installer. 3. Next, specify the destination for the IDE. On some PC operating system versions it may be wise to avoid locations with spaces. It may have a detrimental effect on the Wireless Toolkit. 4. A summary of the installation information gathered from the user is displayed. Also the choice is given to associate Sun ONE Studio with Java file types. 5. Press Next to begin the installation. Upon completion, the user will be told whether it was successful or not. Assuming the installation was fine, the IDE is now ready for use. However, some configuration issues will be asked for, such as the window mode of use for the IDE and some proxy settings. Set these as desired and then continue. Figure 2.18 Sun ONE Studio 4 installation. 74 GETTING STARTED 6. Registration then needs to be made with Sun’s website. This requires the user to enter a username and password, which is the user details used to obtain the software in the first instance. 2.3.2.4 Unified Emulator Interface As more device manufacturers create emulators for content developers, it becomes increasingly difficult for Integrated Development Environment (IDE) makers to support each emulator. Most emulators have different directory structures, different commands and different command-line arguments. A generic unified emulator interface (UEI) that all emulators support is needed. The UEI allows IDE manufacturers to write to a single interface and, with little or no effort, be able to support emulators from many different companies. The UEI specification defines a directory structure for the emu- lator distribution unit (executables, documentation and library files), binary executables (emulator, etc.), names and command line execution arguments. In the next release, Symbian will provide a compliant UEI imple- mentation to facilitate easier and more standard integration of the MIDP emulator with existing IDEs such as JBuilder and Sun ONE Studio. Symbian OS Version 8.0 will support launching a MIDlet in the emulator VM from within the IDE and provide options to start the VM in debug mode to enable debugging with your IDE. You develop and compile in your working folder. When you run the emulator, you would continue to develop in this way, using the IDE, and Symbian UEI takes care of packaging the classes, copying them to the emulator file space and launching the MIDlet. The following example demonstrates how to integrate a UEI-compliant emulator with Sun ONE Studio. Adding the Emulator to Sun ONE Studio 1. From the Explorer window, right-click on Installed Emulators and click on Add Emulator (Figure 2.19). 2. Browse to the directory that contains the distribution unit for the product/platform variant (Figure 2.20). Setting the Default Emulator In the explorer window (Figure 2.19), you should now see the Symbian UEI added to the list of installed emulators. Right-click on Default Emulators and click on Set Default Emulator. From the list of installed emulators, select one of the options (Figure 2.21). INTRODUCTION TO TOOLS FOR MIDP 75 Figure 2.19 Add emulator. Figure 2.20 Browse for udeb. Figure 2.21 Select Emulator. 76 GETTING STARTED Figure 2.22 Run and debug toolbar. Running and Debugging a MIDlet This is done as with any other MIDlet within Sun ONE Studio, using the menus, the shortcuts or the Toolbar (Figure 2.22). The UEI will take care of creating the JAR file and copying it and the descriptor (JAD) file into the appropriate place in the emulator file system and then starting the VM in the required mode. 2.3.3 Device Emulators 2.3.3.1 UIQ SDK Overview The UIQ platform provides the basis for Symbian OS phones that use a pointing device as the means of user input. The UIQ SDK provides developers with the ability to test and develop MIDP 2.0 applications for devices such as the Sony Ericsson P900. The SDK provides classes and the emulator facilitates development of native Symbian, PersonalJava and MIDP 1.0 and 2.0 applications. Developers do not need to install the full SDK to develop MIDP 2.0 applications, as we shall demonstrate in the installation section below. The SDK provides an environment that includes Symbian’s CLDC 1.0-based VM, MIDP 2.0, including the Bluetooth and Wireless Messag- ing APIs. Setting Up the SDK In the first instance, some minor housekeeping needs to be carried out to ensure the tool will execute in a suitable way. First, make sure the path C:\ is in the system path. The EPOCROOT environment variable must be set to the location of the UIQ tool instal- lation. In this case we have used the SET command at the command prompt in Windows as follows: D:\>SET EPOCROOT=<installation of UIQ>\UIQ_21_\ Also, the devices command should be used to check that the default device is the UIQ emulator. Assuming Perl is installed (this can be installed INTRODUCTION TO TOOLS FOR MIDP 77 as part of the installation process), issuing the command devices.exe will return the following: D:\>devices.pl UIQ_21:com.symbian.UIQ – default UIQ_21:com.symbian.UIQ-runtime If this does not appear then the devices.pl command should be used to set the default command to the UIQ tool. This is done in the following way: D:\>devices.exe -setdefault @ UIQ_21:com.symbian.UIQ Once these have been set, the following command can be issued: D:\>epoc.exe -wins -rel This will execute the WinS release version of the emulator. Other versions such as a debug version can also be executed, although these are used for debugging native C++ applications. Once this command has been run, the UIQ 2.1 emulator will appear on the screen. Installing a MIDP 2.0 Application on the Emulator The MIDP packages can be placed in the emulator device’s virtual drive, for example <installation directory>\epoc32\wins\c. This package can be installed from the emulator interface in the follow- ing way: 1. Navigate to the Launcher menu on the emulator and use the mouse to select Install (Figure 2.23). 2. A sub menu prompting the developer to locate the MIDP suite will appear (Figure 2.24). Press the Install button and the MIDlet will be installed. 3. It will appear as an icon on the emulator’s desktop. In this case we have installed our Helloworld application from Section 2.2 (Figure 2.25). Installation The SDK can be downloaded from the Symbian Developer Network at www.symbian.com/developer/sdks uiq21.asp . 1. This download is delivered in the form of a ZIP file which needs to be extracted to a suitable temporary location. 78 GETTING STARTED Figure 2.23 UIQ emulator. Figure 2.24 Install MIDlet. 2. Navigate to the extracted files and execute Setup.exe. The instal- lation process will begin. 3. After accepting terms, conditions and the license agreement, a prompt for the destination of the SDK is given (Figure 2.26). 4. Once this has been selected, you will be prompted to select the components you wish to install (Figure 2.27). The rather greedy system requirement for disk space (Figure 2.26) can be ignored. It refers to the full Symbian ‘‘DevKit’’, which includes the full source code. The example installation was installed on a PC with modest available disk space. A figure of approximately 550 MB, depending upon the packages, example and documentation selected, is more accurate. As well as the packages forming the SDK itself, Perl and a Java 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.0 runtime.) If these are not present on the target PC, then select them as 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 first stage of the installation. If Perl, which is required to run the emulator, INTRODUCTION TO TOOLS FOR MIDP 79 Figure 2.25 Helloworld. and the Java Runtime have been selected, they will also be installed at 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 choose what they want to be installed on the PC. In this case, we are only interested in the emulator, the MIDP package and the documentation, which might help us better understand the SDK. Note that UIQ 2.1 Java SDK has not been selected. This is, in fact, for PersonalJava and therefore we are not interested in installing it in this instance. 8. The installer gathers the packages together and displays the names of all the selected packages and the required disk space. Press Next to continue. Before installing, a prompt appears asking the user to accept the terms of the license. The SDK will then be installed. Once it has been successfully installed, Figure 2.30 appears. 80 GETTING STARTED Figure 2.26 Symbian OS Kit Installer. Figure 2.27 Install components. INTRODUCTION TO TOOLS FOR MIDP 81 Figure 2.28 Ready to install SDK. Figure 2.29 Choosing packages. 2.3.3.2 Sony Ericsson P900 J2ME SDK Also available for UIQ developers is a Sony Ericsson MIDP 2.0 emulator that can be plugged into the Wireless Toolkit, version 2.1. This is a very useful tool for perfecting the user interface side of application development. However, the drawback is that the Java runtime is Sun’s reference implementation, rather than the actual Symbian OS device [...]... CA 1’s public key This is then used to validate CA 100 MIDP 2. 0 AND THE JTWI CA 1's public key 16 839 756107 43 CA 2' s public key 20 926 578 835 65 Supplier's public key 09 636 5 829 6 72 Signed: Root CA Signed: CA 1 < 135 9 32 5 16> Signed: CA 2 jar file Figure 3. 3 Using a certification path to authenticate a signed JAR file 2 s public key, which is then used to validate the Supplier’s... javax.microedition.io.Connector.http, javax.microedition.io.Connector.https, javax.microedition.io.Connector.datagram, javax.microedition.io.Connector.datagramreceiver, javax.microedition.io.Connector.socket, javax.microedition.io.Connector.serversocket, javax.microedition.io.Connector.ssl domain: Untrusted session (oneshot): net_access oneshot (oneshot): javax.microedition.io.Connector.sms.send oneshot (oneshot): javax.microedition.io.Connector.sms.receive... 2. 32 ) The softkeys display Yes and No options Selecting No cancels the installation Select Yes and you will be shown two options (Figure 2. 33 ) Selecting View Details displays information from the JAD file (Figure 2. 34 ) Figure 2. 32 AMS checks that installation is required Figure 2. 33 AMS gives user the option to view details INSTALLING AND RUNNING A MIDLET 87 Figure 2. 34 JAD file information Figure 2. 35 ... javax.microedition.lcdui • javax.microedition.lcdui.game • javax.microedition.media • javax.microedition.media.control Furthermore, the specification requires that the following APIs can be accessed with explicit permission of the user: • javax.microedition.io.HttpConnection • javax.microedition.io.HttpsConnection The full list of permissions for the untrusted domain is device-specific however the MIDP 2. 0... javax.microedition.io.Connector.sms.receive session (oneshot): javax.microedition.io.PushRegistry domain: Symbian allow: net_access allow: javax.microedition.io.Connector.sms.send allow: javax.microedition.io.Connector.sms.receive allow: javax.microedition.io.PushRegistry User permissions may offer several interaction modes, the user being able to select the level of access For instance, the following line indicates that... Media API (JSR 135 ) as part of the Java platform Current Symbian MIDP 2. 0-enabled phones support the following JSRs: Nokia 6600 UI Reference Design CLDC 1.0 (JSR 30 ) MIDP 2. 0 (JSR 118) WMA (JSR 120 ) MMA (JSR 135 ) JABWT (JSR 82) Sony Ericsson P900/P908 Series 60 v 2 Yes Yes Yes Yes Yes UIQ 2. 1 Yes Yes Yes No Yes Because the final release of the JTWI specification postdated that of the MIDP 2. 0 specification... implement the MIDP 2. 0 security model and support at least one trusted protection domain 3. 3 .2. 12 Security Model on Symbian OS Phones At the time of writing the current MIDP 2. 0 phones based on Symbian OS are the Sony Ericsson P900/P908 and the Nokia 6600 The Sony Ericsson P900/P908 (Organizer firmware versions R2B 02 or later) provides support for a single trusted protection domain and therefore supports... prompted for a location for the MIDlet (Figure 2. 37 ) This allows the user to determine whether to install the MIDlet on the phone memory or the removable multimedia card Use the joystick to choose one of the two options and press OK Figure 2. 38 illustrates what then appears 88 GETTING STARTED Figure 2. 36 AMS detects that an existing application will be upgraded Figure 2. 37 Specifying the location Figure 2. 38 ... application will be executed 2. 5 MIDP on Symbian OS Phones All Symbian OS phones currently available in Western markets support at least MIDP 1.0 The latest generation of Symbian OS phones, such as the Nokia 6600 and Sony Ericsson P900 (and its localized variants) ship with MIDP 2. 0 The Nokia 6600 is based on the Series 60 Developer Platform 2. 0, itself built on top of Symbian OS Version 7.0s The Sony... Jode  20 04 Symbian Ltd ISBN: 0-470-0 922 3- 8 92 MIDP 2. 0 AND THE JTWI 3. 1.1 Component JSRs of the JTWI The JTWI defines three categories of JSR that fall under the specification: mandatory, conditionally required and minimum configuration The following mandatory JSRs must be implemented as part of a Java platform that is compliant with JTWI Release 1: • MIDP 2. 0 (JSR 118) • Wireless Messaging API (JSR 120 ) . 2. 26 Symbian OS Kit Installer. Figure 2. 27 Install components. INTRODUCTION TO TOOLS FOR MIDP 81 Figure 2. 28 Ready to install SDK. Figure 2. 29 Choosing packages. 2. 3. 3 .2 Sony Ericsson P900 J2ME. specifications, where appro- priate. Programming Java 2 Micro Edition on Symbian OS: A developer’s guide to MIDP 2. 0 . Martin de Jode  20 04 Symbian Ltd ISBN: 0-470-0 922 3- 8 . the options (Figure 2. 21). INTRODUCTION TO TOOLS FOR MIDP 75 Figure 2. 19 Add emulator. Figure 2. 20 Browse for udeb. Figure 2. 21 Select Emulator. 76 GETTING STARTED Figure 2. 22 Run and debug toolbar. Running

Ngày đăng: 09/08/2014, 18:22

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan