Programming Java 2 Micro Edition for Symbian OS 2004 (779882), страница 18
Текст из файла (страница 18)
The Wireless Toolkit has beenintegrated with the IDE. It also comes with plenty of examples to get thedeveloper started, both with the IDE and with MIDP development.There is a free offering of the IDE from the Sun Java website at the following location: http://wwws.sun.com/software/sundev/jde/studio me/index.html). The free version can be used for non-commercial evaluationpurposes. In the same way that JBuilder 9 can be integrated with theNokia Developer’s Suite, so can this IDE.The text editor offers code completion and contextual shortcut menusto save the developer having to search for commands.
A project navigatoris also available, as is version control through its ”VCS groups” andCVS functions.While this book will be examining version 4 of the software, it shouldbe noted that at the time of writing an early access edition of version 5.0was being released. While this is not a full production release it is worthnoting 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 J2MEapplications• integration of third-party device SDKs through the emulator registry• XML-file-based emulator configuration and integration• sample MIDlets to get the developer started.InstallationThe 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.0INTRODUCTION TO TOOLS FOR MIDP73As a runtime environment, it requires J2SE at version 1.3.1, 1.4.0, or1.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 foundthen accept it, otherwise its location, if present on the PC, should begiven to the installer.3. Next, specify the destination for the IDE. On some PC operatingsystem versions it may be wise to avoid locations with spaces. It mayhave a detrimental effect on the Wireless Toolkit.4. A summary of the installation information gathered from the user isdisplayed. Also the choice is given to associate Sun ONE Studio withJava file types.5.
Press Next to begin the installation. Upon completion, the user willbe told whether it was successful or not. Assuming the installationwas fine, the IDE is now ready for use. However, some configurationissues will be asked for, such as the window mode of use for the IDEand some proxy settings. Set these as desired and then continue.Figure 2.18Sun ONE Studio 4 installation.746.GETTING STARTEDRegistration then needs to be made with Sun’s website. This requiresthe user to enter a username and password, which is the user detailsused to obtain the software in the first instance.2.3.2.4 Unified Emulator InterfaceAs more device manufacturers create emulators for content developers, itbecomes increasingly difficult for Integrated Development Environment(IDE) makers to support each emulator.
Most emulators have differentdirectory structures, different commands and different command-linearguments. A generic unified emulator interface (UEI) that all emulatorssupport is needed. The UEI allows IDE manufacturers to write to a singleinterface and, with little or no effort, be able to support emulators frommany different companies.The UEI specification defines a directory structure for the emulator distribution unit (executables, documentation and library files),binary executables (emulator, etc.), names and command line executionarguments.In the next release, Symbian will provide a compliant UEI implementation to facilitate easier and more standard integration of the MIDPemulator with existing IDEs such as JBuilder and Sun ONE Studio.Symbian OS Version 8.0 will support launching a MIDlet in theemulator VM from within the IDE and provide options to start the VMin debug mode to enable debugging with your IDE.
You develop andcompile in your working folder. When you run the emulator, you wouldcontinue to develop in this way, using the IDE, and Symbian UEI takescare of packaging the classes, copying them to the emulator file spaceand launching the MIDlet.The following example demonstrates how to integrate a UEI-compliantemulator with Sun ONE Studio.Adding the Emulator to Sun ONE Studio1.From the Explorer window, right-click on Installed Emulators andclick on Add Emulator (Figure 2.19).2.Browse to the directory that contains the distribution unit for theproduct/platform variant (Figure 2.20).Setting the Default EmulatorIn the explorer window (Figure 2.19), you should now see the SymbianUEI added to the list of installed emulators. Right-click on DefaultEmulators and click on Set Default Emulator.
From the list of installedemulators, select one of the options (Figure 2.21).INTRODUCTION TO TOOLS FOR MIDPFigure 2.19 Add emulator.Figure 2.20Browse for udeb.Figure 2.21Select Emulator.7576GETTING STARTEDFigure 2.22Run and debug toolbar.Running and Debugging a MIDletThis is done as with any other MIDlet within Sun ONE Studio, using themenus, the shortcuts or the Toolbar (Figure 2.22). The UEI will take careof creating the JAR file and copying it and the descriptor (JAD) file intothe appropriate place in the emulator file system and then starting the VMin the required mode.2.3.3 Device Emulators2.3.3.1 UIQ SDKOverviewThe UIQ platform provides the basis for Symbian OS phones that usea pointing device as the means of user input.
The UIQ SDK providesdevelopers with the ability to test and develop MIDP 2.0 applications fordevices such as the Sony Ericsson P900. The SDK provides classes andthe emulator facilitates development of native Symbian, PersonalJava andMIDP 1.0 and 2.0 applications. Developers do not need to install the fullSDK to develop MIDP 2.0 applications, as we shall demonstrate in theinstallation section below.The SDK provides an environment that includes Symbian’s CLDC1.0-based VM, MIDP 2.0, including the Bluetooth and Wireless Messaging APIs.Setting Up the SDKIn the first instance, some minor housekeeping needs to be carried out toensure the tool will execute in a suitable way.First, make sure the path C:\ is in the system path. The EPOCROOTenvironment variable must be set to the location of the UIQ tool installation. In this case we have used the SET command at the commandprompt in Windows as follows:D:\>SET EPOCROOT=<installation of UIQ>\UIQ_21_\Also, the devices command should be used to check that the defaultdevice is the UIQ emulator.
Assuming Perl is installed (this can be installedINTRODUCTION TO TOOLS FOR MIDP77as part of the installation process), issuing the command devices.exewill return the following:D:\>devices.plUIQ_21:com.symbian.UIQ – defaultUIQ_21:com.symbian.UIQ-runtimeIf this does not appear then the devices.pl command should beused to set the default command to the UIQ tool. This is done in thefollowing way:D:\>devices.exe -setdefault @ UIQ_21:com.symbian.UIQOnce these have been set, the following command can be issued:D:\>epoc.exe -wins -relThis will execute the WinS release version of the emulator.
Otherversions such as a debug version can also be executed, although theseare used for debugging native C++ applications. Once this command hasbeen run, the UIQ 2.1 emulator will appear on the screen.Installing a MIDP 2.0 Application on the EmulatorThe MIDP packages can be placed in the emulator device’s virtualdrive, for example <installation directory>\epoc32\wins\c.This package can be installed from the emulator interface in the following way:1. Navigate to the Launcher menu on the emulator and use the mouseto select Install (Figure 2.23).2.