Francisco Benitez Leon's Blog

August 13, 2009

Integrating S60 3rd Edition FP1 SDK for Symbian OS with NetBeans IDE 6.5

Filed under: Java ME — Tags: , , , , — Francisco Benitez Leon @ 12:17 am

Recently I broke part of my developing environment consisting of a NetBeans IDE 6.1 installation, on Windows XP SP2, in which I had integrated several Java ME platforms for developing mobile applications. I tried to install the S60 5th Edition SDK for Symbian OS without paying to much attention and trying to fix the mess (I wasn’t able to launch applications on the SDK from NetBeans) I ended up breaking two more platforms, the S60 3rd Edition FP1 SDK for Symbian OS and the FP2 SDK.

I decided to reinstall the platforms and I thought it was worth upgrading the IDE, so I tried to set up the same environment with NetBeans IDE 6.7 and the S60 SDKs. Unfortunately I had no success, I’m not sure but I think it was because of the ActivePerl version. The S60 3rd Ed. FP2 requires ActivePerl 5.6.1.638 or newer and the S60 5th Ed. SDK requires exactly the 5.6.1 version, I had installed ActivePerl 5.10.0.1005. At this time I had to reinstall again so I used google and read that the NetBeans recommended version for S60 5th Ed. was 6.5. You know how this end, I set up the environment correctly with NetBeans IDE 6.5. I added the three S60 SDKs as Java ME platforms to NetBeans and tested all the configurations. You have to be patient with S60 SDKs as they all emulate the complete Symbian OS and have a long startup time. Sometimes the first time you launch an application on the emulator from the NetBeans, a NullPointerException is thrown because the emulator takes too long to start.  In these cases I relaunch the process and everything works like a charm.

So I had all my new development environment set up and working, and  then …

… I realized of the NetBeans’ Project Platform Properties window for the S60 3rd Ed. FP1 SDK, where were the optional packages?

NetBeans Project Platform Properties window for S60 3rd Edition FP1 for Symbian OS, most optional packages missing

NetBeans Project Platform Properties window for S60 3rd Edition FP1 for Symbian OS, most optional packages missing

The fact is that it seems that the Optional Packages choice group is not working properly for this Java ME Platform. The only package that is selectable is the Java ME Web Services package but whether you select it or not it is always present. You could check it adding the following lines to one MIDlet:

import javax.xml.namespace.QName; //part of JSR-172 Java ME Web Services
...
          public void startApp()  {
                     ...
                     QName test = QName("test");
                     ...
          }
...

It will compile whether you checked the JSR-000172 or not, it is enabled by default as you will see. This is an inconvenience as I don’t want to add more libraries than the extrictly necessary.

I didn’t want to reinstall again so I added the platform to my NetBeans 6.1 and looked at the Project Platform Properties window, and all the optional packages were selectable. I guess that something had changed in NetBeans from versions 6.1 to 6.5 that was preventing the IDE from discriminating among these optional packages.

I am going to tell you how I managed to solve this problem but if you don’t know how to add the platforms to the IDE you could follow these guidelines first.

Making S60 3rd Edition FP1 SDK optional packages selectable from NeatBeans 6.5

To be successful you’ll need to have installed NetBeans IDE 6.5, S60 3rd Edition FP1 and FP2 SDKs (first install the IDE and next you should install the SDKs following its installation instructions). The SDKs have to be integrated with NetBeans as Java ME platforms, and at last you’ll have to do a little hacking with the SDKs and NetBeans to get it working.

The Java ME platform configuration files in NetBeans are located in:

%USERDIR%\.netbeans\6.5\config\Services\Platforms\org-netbeans-api-java-Platform

, you will see one for each Java ME platform you have added. Before going any further you should spend some time understanding the NetBeans Java ME Platform definition DTD 1.0 which is really simple. Here is a brief formatted description of the main elements presented in the DTD:

  • Element platform – defines the Java ME platform with the following attributes:
    • name – identification of the platform. The platform is always referenced by the name so the name must be unique among all installed platforms within the IDE.
    • home – base folder of the platform installation.
    • type – platform type. Valid values are currently: UEI-1.0, UEI-1.0.1, and CUSTOM.
    • displayname – displayed name of the platform. When not specified name is used instead.
    • srcpath – optional list of folders, jars and zip files with platform sources.
    • docpath – optional list of folders, jars, zip files and URLs containing platform JavaDoc.
  • Element device – defines the devices supported by the Java ME platform, with the following attributes:
    • name – device name is the unique identification of the device within the platform.
    • description – optional description of the device.

    And the following elements:

    • configuration – Java ME device configuration. It should be at least one present. Its attributes are:
      • name – configuration name will usually be CLDC.
      • version – version number in text format. For example: 1.0
      • displayname – expanded name of the configuration. For example: Connected Limited Device Configuration.
      • classpath – comma separated list of folders, jars and zip files that belong to the configuration.
      • default – boolean specifying if this configuration is default. Valid values are true or false. Exactly one configuration must be set as default.
    • profile – Java ME device profile. It should be at least one present. Its attributes are:
      • name – profile name will usually be MIDP.
      • version – version number in text format. For example 1.0.
      • dependencies – list of configuration dependencies.
      • displayname – expanded name of the profile. For example: Mobile Information Device Profile.
      • classpath – comma separated list of folders, jars and zip files that belong to the profile.
      • default – boolean specifying if this profile is default. Valid values are true or false. Exactly one profile must be set as default.
    • optional – Java ME device optional packages. It could be present none, one or more. Its attributes are:
      • name – optional API name, for example MMAPI.
      • version – version number in text format, for example 1.0.
      • dependencies – list of dependencies on configurations, profiles, or other optional APIs of the same device.
      • displayname – expanded name of the optional API. For example: Mobile Media API.
      • classpath – comma separated list of folders, jars and zip files that belong to the optional API.
      • default – boolean identification specifying if this optional API is enabled by default. Valid values are true or false. Any number of optional APIs may be enabled by default. As I told you before, in the added S60 3rd Edition FP1 SDK all the optional packages are enabled by default.
    • screen – device screen details. If present there shouldn’t be more than one. Its attributes are:
      • width
      • height
      • bitDepth
      • isColortrue by default
      • isTouchfalse by default

Now that you are an expert on NetBeans Java ME Platform definition DTD 1.0 we could go on and inspect the S60 FP1 platform XML configuration file. In my case is named S60_3rd_Edition_FP1_SDK_for_MIDP.xml and its content, skipped the S60Device section for clarity, is:

<?xml version='1.0'?>
<!DOCTYPE platform PUBLIC '-//NetBeans//DTD J2ME PlatformDefinition 1.0//EN' 'http://www.netbeans.org/dtds/j2me-platformdefinition-1_0.dtd'>
<platform name="S60_3rd_Edition_FP1_SDK_for_MIDP" home="C:\S60\devices\S60_3rd_MIDP_SDK_FP1" type="UEI-1.0" displayname="S60 3rd Edition FP1 SDK for MIDP" srcpath="" docpath="${platform.home}/docs/AMMS_JSR-234,${platform.home}/docs/Bluetooth_JSR-82,${platform.home}/docs/CLDC1.1_JSR-139,${platform.home}/docs/FileConnectionOptionalPackage_JSR-75,${platform.home}/docs,${platform.home}/docs/Location_JSR-179,${platform.home}/docs/MIDProfile_JSR-118,${platform.home}/docs/Mobile3DGraphics_JSR-184,${platform.home}/docs/MobileMedia_JSR-135,${platform.home}/docs/NokiaUI,${platform.home}/docs/PIMOptionalPackage_JSR-75,${platform.home}/docs/SATSA_JSR-177,${platform.home}/docs/Scalable2DVectorGraphics_JSR-226,${platform.home}/docs/SDK_Help,${platform.home}/docs/SIP_JSR-180,${platform.home}/docs/WebServicesjaxp_JSR-172,${platform.home}/docs/WebServicesjaxrpc_JSR-172,${platform.home}/docs/WMA_2.0,${platform.home}/docs/WMA_JSR-120,${platform.home}/S60examples/AMMSMIDlet/doc/javadoc,${platform.home}/S60examples/btl2capEcho/doc/javadoc,${platform.home}/S60examples/btsppEcho/doc/javadoc,${platform.home}/S60examples/capitalclient/doc/javadoc,${platform.home}/S60examples/capitalservlet/build/javadoc,${platform.home}/S60examples/chat/doc/javadoc,${platform.home}/S60examples/devicecap/doc/javadoc,${platform.home}/S60examples/doc-files,${platform.home}/S60examples/fileconnection/doc/javadoc,${platform.home}/S60examples/filehandler/doc/javadoc,${platform.home}/S60examples/golfhelper/doc/javadoc,${platform.home}/S60examples/hawk/doc/javadoc,${platform.home}/S60examples/helloworldplus/doc/javadoc,${platform.home}/S60examples/m3g/doc/javadoc,${platform.home}/S60examples/mms/doc/javadoc,${platform.home}/S60examples/personalcontroller/doc/javadoc,${platform.home}/S60examples/pki/doc/javadoc,${platform.home}/S60examples/push/doc/javadoc,${platform.home}/S60examples/security/doc/javadoc,${platform.home}/S60examples/sheepdog/doc/javadoc,${platform.home}/S60examples/shopping/doc/javadoc,${platform.home}/S60examples/sip/doc/javadoc,${platform.home}/S60examples/svg/doc/javadoc,${platform.home}/S60examples/XMLParser/doc/javadoc,">
    <device name="S60Emulator" description="S60Emulator">
        <optional name="JSR172" version="1.0" displayname="Java ME Web Services" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="OBEX" version="1.0" displayname="Object Exchange APIs" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="JSR179" version="1.0" displayname="Location Based APIs" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="JSR75" version="1.0" displayname="File Connection and PIM Optional Packages" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="WMA" version="2.0" displayname="Wireless Messaging API" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="JSR82" version="1.0" displayname="Java APIs for Bluetooth Wireless Technology" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="JSR184" version="1.0" displayname="Mobile 3D Graphics Optional Package" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
<profile name="MIDP" version="2.0" displayname="Mobile Information Device Profile" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="NOKIAUI" version="1.0" displayname="Nokia User Interface" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <configuration name="CLDC" version="1.1" displayname="Connected Limited Device Configuration" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <optional name="MMAPI" version="1.0" displayname="Mobile Media API" classpath="${platform.home}/lib/hmidps60v31.jar" dependencies="" default="true"/>
        <screen width="240" height="320" bitDepth="12" isColor="true" isTouch="false"/>
    </device>
    <device name="S60Device" description="S60Device">
        ...
    </device>
</platform>

As you can see all the optional packages are bundled with the configuration (CLDC 1.1) and profile (MIDP 2.0) in the file hmidps60v31.jar. This is because the SDK implementation presents its complete Java ME execution environment in one jar.

In the case of the S60 FP2 platform most of the optional packages are standalone jars, as you can see in its NetBeans’ Java ME platform configuration XML file, named S60_3rd_Edition_SDK_for_Symbian_OS__Feature_Pack_2_v1_1.xml:

<?xml version='1.0'?>
<!DOCTYPE platform PUBLIC '-//NetBeans//DTD J2ME PlatformDefinition 1.0//EN' 'http://www.netbeans.org/dtds/j2me-platformdefinition-1_0.dtd'>
<platform name="S60_3rd_Edition_SDK_for_Symbian_OS__Feature_Pack_2_v1_1" home="C:\S60\devices\S60_3rd_FP2_SDK_v1.1" type="UEI-1.0.1" displayname="S60 3rd Edition SDK for Symbian OS, Feature Pack 2 v1.1" srcpath="" docpath="${platform.home}/docs,${platform.home}/docs/javadocs/GUID-07274ED2-697C-4987-ABE9-7FFE82605633,${platform.home}/docs/javadocs/GUID-0D0A1092-5037-4421-B466-B958CB777414,${platform.home}/docs/javadocs/GUID-233D0FA4-C649-4220-829B-5CEA8B6559DD,${platform.home}/docs/javadocs/GUID-237420DE-CCBE-4A74-A129-572E0708D428,${platform.home}/docs/javadocs/GUID-2508C2ED-C0BE-4512-9302-6805AB7ACB0E,${platform.home}/docs/javadocs/GUID-32B0EEEB-D06F-4387-8133-DF5F0D0C0D70,${platform.home}/docs/javadocs/GUID-47BB9F00-FE65-484D-BD71-F54AF5884D32,${platform.home}/docs/javadocs/GUID-4AEC8DAF-DDCC-4A30-B820-23F2BA60EA52,${platform.home}/docs/javadocs/GUID-654A42A3-C453-411A-A153-366C08AEF058,${platform.home}/docs/javadocs/GUID-67FFFB36-2BD8-442C-A4A8-252289CA2B3C,${platform.home}/docs/javadocs/GUID-71D2FC38-3A7C-4F69-9A2C-C307ABF33D6C,${platform.home}/docs/javadocs/GUID-8F9BE454-FC5E-4B87-B805-765DEFA66C99,${platform.home}/docs/javadocs/GUID-9F75713D-5642-4C39-9A33-C20928F37BF7,${platform.home}/docs/javadocs/GUID-A8A297BB-EA23-4E2C-A9D1-6403BBEE0CD9/Appendix2-javadocs,${platform.home}/docs/javadocs/GUID-A8A297BB-EA23-4E2C-A9D1-6403BBEE0CD9,${platform.home}/docs/javadocs/GUID-D3E35E6F-0C45-48ED-B09D-F716E14C1C02,${platform.home}/docs/javadocs/GUID-D69FC49D-783E-45CE-80D4-7A9F3EE08B2A,${platform.home}/S60CppExamples/AddressBook/doc,${platform.home}/S60CppExamples/aiwconsumerbasics/doc,${platform.home}/S60CppExamples/Animation/doc,${platform.home}/S60CppExamples/AudioStreamExample/doc,${platform.home}/S60CppExamples/BrCtlSampleApp/doc,${platform.home}/S60CppExamples/Chat/doc,${platform.home}/S60CppExamples/CLFExample/doc,${platform.home}/S60CppExamples/ClientServerAsync/doc,${platform.home}/S60CppExamples/ClientServerSync/doc,${platform.home}/S60CppExamples/Contacts/doc,${platform.home}/S60CppExamples/DataMobility/doc,${platform.home}/S60CppExamples/DirectoryLocalizerEx/doc,${platform.home}/S60CppExamples/DriveInfo/doc,${platform.home}/S60CppExamples/DynamicSettingList/doc,${platform.home}/S60CppExamples/Filelist/doc,${platform.home}/S60CppExamples/finditemtestapp/doc,${platform.home}/S60CppExamples/Focusevent/doc,${platform.home}/S60CppExamples/Graphics/doc,${platform.home}/S60CppExamples/GuiEngine/doc,${platform.home}/S60CppExamples/helloworldbasic/doc,${platform.home}/S60CppExamples/HelpExample/doc,${platform.home}/S60CppExamples/hwrmtestapp/doc,${platform.home}/S60CppExamples/IMOpenAPIExample/doc,${platform.home}/S60CppExamples/IsvTelCallApp/doc,${platform.home}/S60CppExamples/IsvTelInfoApp/doc,${platform.home}/S60CppExamples/Listbox/doc,${platform.home}/S60CppExamples/Localization/doc,${platform.home}/S60CppExamples/LocationLandmarksRefAppForS60/doc,${platform.home}/S60CppExamples/LocationLandmarksUIRefApp/doc,${platform.home}/S60CppExamples/LocationRefAppForS60/doc,${platform.home}/S60CppExamples/LocationSatViewRefApp/doc,${platform.home}/S60CppExamples/Messaging/doc,${platform.home}/S60CppExamples/MyView/doc,${platform.home}/S60CppExamples/Note/doc,${platform.home}/S60CppExamples/NPBitmap/doc,${platform.home}/S60CppExamples/OcrExample/doc,${platform.home}/S60CppExamples/OpenC_Ex/antiword/doc,${platform.home}/S60CppExamples/OpenC_Ex/handleglobalvar/doc,${platform.home}/S60CppExamples/OpenC_Ex/openchelloglibeventex/doc,${platform.home}/S60CppExamples/OpenC_Ex/openclibz/doc,${platform.home}/S60CppExamples/OpenC_Ex/opencmessagequeuelibraryex/doc,${platform.home}/S60CppExamples/OpenC_Ex/opencopenglex/doc,${platform.home}/S60CppExamples/OpenC_Ex/opencproducerconsumerex/doc,${platform.home}/S60CppExamples/OpenC_Ex/OpenCStringUtilitiesEx/doc,${platform.home}/S60CppExamples/OpenC_Ex/redirectprintf/doc,${platform.home}/S60CppExamples/OpenC_Ex/simulateactiveobject/doc,${platform.home}/S60CppExamples/OpenGLEx/Billboard/doc,${platform.home}/S60CppExamples/OpenGLEx/Bumpmap/doc,${platform.home}/S60CppExamples/OpenGLEx/EnvMapping/doc,${platform.home}/S60CppExamples/OpenGLEx/FloatingDuck/doc,${platform.home}/S60CppExamples/OpenGLEx/Hierarchy/doc,${platform.home}/S60CppExamples/OpenGLEx/LensFlare/doc,${platform.home}/S60CppExamples/OpenGLEx/Mipmapping/doc,${platform.home}/S60CppExamples/OpenGLEx/MultiTex/doc,${platform.home}/S60CppExamples/OpenGLEx/Particles/doc,${platform.home}/S60CppExamples/OpenGLEx/PickSelect/doc,${platform.home}/S60CppExamples/OpenGLEx/Rain/doc,${platform.home}/S60CppExamples/OpenGLEx/Shadows/doc,${platform.home}/S60CppExamples/OpenGLEx/SimpleCube/doc,${platform.home}/S60CppExamples/OpenGLEx/SimpleCubePbuffer/doc,${platform.home}/S60CppExamples/OpenGLEx/SimpleCubePixmap/doc,${platform.home}/S60CppExamples/OpenGLEx/SimpleLight/doc,${platform.home}/S60CppExamples/OpenGLEx/Slideshow/doc,${platform.home}/S60CppExamples/OpenGLEx/Snow/doc,${platform.home}/S60CppExamples/OpenGLEx/Texture/doc,${platform.home}/S60CppExamples/PopupField/doc,${platform.home}/S60CppExamples/PopupList/doc,${platform.home}/S60CppExamples/ProgressBar/doc,${platform.home}/S60CppExamples/Query/doc,${platform.home}/S60CppExamples/Registration/doc,${platform.home}/S60CppExamples/RichTextEditor/doc,${platform.home}/S60CppExamples/SIPExample/doc,${platform.home}/S60CppExamples/UnitEditorEx/doc,${platform.home}/S60CppExamples/WebClient/doc,${platform.home}/S60CppExamples/_doc,${platform.home}/S60MIDPExamples/IAPInfoMIDlet/doc/javadoc,">
    <device name="S60Emulator" securitydomains="Manufacturer,Operator,Trusted_Third_Party,Untrusted,User_defined,Minimal" description="S60Emulator">
        <optional name="JSR172" version="1.0" displayname="Java ME Web Services" classpath="${platform.home}/lib/JSR172.jar" dependencies="" default="true"/>
        <optional name="JSR234" version="1.0" displayname="ADVANCE MULTIMEDIA SUPPLEMENT" classpath="${platform.home}/lib/JSR234.jar" dependencies="" default="true"/>
        <optional name="OBEX" version="1.0" displayname="Object Exchange APIs" classpath="${platform.home}/lib/JSR82.jar" dependencies="" default="true"/>
        <optional name="SATSA" version="1.2" displayname="Security APIs" classpath="${platform.home}/lib/JSR177.jar" dependencies="CLDC > 1.0" default="true"/>
        <optional name="JSR179" version="1.0" displayname="Location Based APIs" classpath="${platform.home}/lib/JSR179.jar" dependencies="CLDC >= 1.0" default="true"/>
        <optional name="JSR75" version="1.0" displayname="File Connection and PIM Optional Packages" classpath="${platform.home}/lib/JSR75.jar" dependencies="CLDC = 1.1" default="true"/>
        <optional name="JSR226" version="1.0" displayname="MOBILE 2D Graphics" classpath="${platform.home}/lib/JSR226.jar" dependencies="" default="true"/>
<profile name="MIDP" version="2.1" displayname="Mobile Information Device Profile" classpath="${platform.home}/lib/midp21.jar" dependencies="CLDC > 1.0" default="true"/>
        <optional name="WMA" version="2.0" displayname="Wireless Messaging API" classpath="${platform.home}/lib/wma20.jar" dependencies="" default="true"/>
        <optional name="WMA" version="1.1" displayname="Wireless Messaging API" classpath="${platform.home}/lib/wma11.jar" dependencies="" default="true"/>
        <optional name="J2ME-XMLRPC" version="1.0" displayname="J2ME XML/RPC" classpath="${platform.home}/lib/JSR172.jar" dependencies="CLDC >= 1.0" default="true"/>
        <optional name="JSR180" version="1.0" displayname="SIP" classpath="${platform.home}/lib/JSR180.jar" dependencies="" default="true"/>
        <optional name="JSR82" version="1.1" displayname="Java APIs for Bluetooth Wireless Technology" classpath="${platform.home}/lib/JSR82.jar" dependencies="CLDC" default="true"/>
        <optional name="JSR184" version="1.0" displayname="Mobile 3D Graphics Optional Package" classpath="${platform.home}/lib/JSR184.jar" dependencies="" default="true"/>
<profile name="MIDP" version="2.0" displayname="Mobile Information Device Profile" classpath="${platform.home}/lib/midp20.jar" dependencies="CLDC > 1.0" default="true"/>
        <optional name="ESWT" version="1.0.3" displayname="ESWT" classpath="${platform.home}/lib/eswt.jar" dependencies="CLDC = 1.1" default="true"/>
        <optional name="NOKIAUI" version="1.0" displayname="Nokia User Interface" classpath="${platform.home}/lib/JSR139.jar" dependencies="" default="true"/>
        <optional name="MMAPI" version="1.2" displayname="Mobile Media API" classpath="${platform.home}/lib/JSR135.jar" dependencies="CLDC > 1.0" default="true"/>
        <configuration name="CLDC" version="1.1" displayname="Connected Limited Device Configuration" classpath="${platform.home}/lib/JSR139.jar" dependencies="" default="true"/>
        <optional name="MMAPI" version="1.0" displayname="Mobile Media API" classpath="${platform.home}/lib/midp21.jar" dependencies="" default="true"/>
        <screen width="240" height="320" bitDepth="12" isColor="true" isTouch="false"/>
    </device>
    <device name="S60Device" securitydomains="Manufacturer,Operator,Trusted_Third_Party,Untrusted,User_defined,Minimal" description="S60Device">
         ...
    </device>
</platform>

This seems to confirm the hypothesis about the bundled jar with the optional packages being the cause of the problem. To make them selectable in the Project’s Platform Properties window you’ll have to copy, for the optional packages in S60_3rd_Edition_FP1_SDK_for_MIDP.xml, the standalone jars from the S60 FP2 SDK lib directory (e.g. C:\S60\devices\S60_3rd_FP2_SDK_v1.1\lib) to the S60 FP1 SDK lib directory (C:\S60\devices\S60_3rd_MIDP_SDK_FP1\lib).

To know which jar you’ll have to copy from S60 FP2 lib to S60 FP1 lib you should consult the NetBeans Java ME Platform configuration file for the S60 3rd Edition FP2 SDK, S60_3rd_Edition_SDK_for_Symbian_OS__Feature_Pack_2_v1_1.xml. For example, to know which jar I should use as S60 3rd Edition FP1 SDK Java ME Web Services (JSR-172) I look for this optional package in S60_3rd_Edition_SDK_for_Symbian_OS__Feature_Pack_2_v1_1.xml and copy the required jar, JSR172.jar, from the S60 FP2 lib to the S60 FP1 lib directory.

copy %S60_3RD_EDITION_FP2_SDK_HOME%\lib\JSR172.jar %S60_3RD_EDITION_FP1_SDK_HOME%\lib

Where,

  • S60_3RD_EDITION_FP1_SDK_HOME = C:\S60\devices\S60_3rd_MIDP_SDK_FP1 is the HOME path for the S60 3rd Edition FP1 SDK.
  • S60_3RD_EDITION_FP2_SDK_HOME = C:\S60\devices\S60_3rd_FP2_SDK_v1.1 is the HOME path for the S60 3rd Edition FP2 SDK.

Next, you should update the S60_3rd_Edition_FP1_SDK_for_MIDP.xml file with these new libraries or add a new Java ME platform. I chose to add a new one named “S60 3rd Edition FP1 SDK for MIDP New” and leave unchanged the original one:

<?xml version='1.0'?>
<!DOCTYPE platform PUBLIC '-//NetBeans//DTD J2ME PlatformDefinition 1.0//EN' 'http://www.netbeans.org/dtds/j2me-platformdefinition-1_0.dtd'>
<platform name="S60_3rd_Edition_FP1_SDK_for_MIDP_New" home="C:\S60\devices\S60_3rd_MIDP_SDK_FP1" type="UEI-1.0" displayname="S60 3rd Edition FP1 SDK for MIDP New" srcpath="" docpath="${platform.home}/docs/AMMS_JSR-234,${platform.home}/docs/Bluetooth_JSR-82,${platform.home}/docs/CLDC1.1_JSR-139,${platform.home}/docs/FileConnectionOptionalPackage_JSR-75,${platform.home}/docs,${platform.home}/docs/Location_JSR-179,${platform.home}/docs/MIDProfile_JSR-118,${platform.home}/docs/Mobile3DGraphics_JSR-184,${platform.home}/docs/MobileMedia_JSR-135,${platform.home}/docs/NokiaUI,${platform.home}/docs/PIMOptionalPackage_JSR-75,${platform.home}/docs/SATSA_JSR-177,${platform.home}/docs/Scalable2DVectorGraphics_JSR-226,${platform.home}/docs/SDK_Help,${platform.home}/docs/SIP_JSR-180,${platform.home}/docs/WebServicesjaxp_JSR-172,${platform.home}/docs/WebServicesjaxrpc_JSR-172,${platform.home}/docs/WMA_2.0,${platform.home}/docs/WMA_JSR-120,${platform.home}/S60examples/AMMSMIDlet/doc/javadoc,${platform.home}/S60examples/btl2capEcho/doc/javadoc,${platform.home}/S60examples/btsppEcho/doc/javadoc,${platform.home}/S60examples/capitalclient/doc/javadoc,${platform.home}/S60examples/capitalservlet/build/javadoc,${platform.home}/S60examples/chat/doc/javadoc,${platform.home}/S60examples/devicecap/doc/javadoc,${platform.home}/S60examples/doc-files,${platform.home}/S60examples/fileconnection/doc/javadoc,${platform.home}/S60examples/filehandler/doc/javadoc,${platform.home}/S60examples/golfhelper/doc/javadoc,${platform.home}/S60examples/hawk/doc/javadoc,${platform.home}/S60examples/helloworldplus/doc/javadoc,${platform.home}/S60examples/m3g/doc/javadoc,${platform.home}/S60examples/mms/doc/javadoc,${platform.home}/S60examples/personalcontroller/doc/javadoc,${platform.home}/S60examples/pki/doc/javadoc,${platform.home}/S60examples/push/doc/javadoc,${platform.home}/S60examples/security/doc/javadoc,${platform.home}/S60examples/sheepdog/doc/javadoc,${platform.home}/S60examples/shopping/doc/javadoc,${platform.home}/S60examples/sip/doc/javadoc,${platform.home}/S60examples/svg/doc/javadoc,${platform.home}/S60examples/XMLParser/doc/javadoc,">
    <device name="S60Emulator" description="S60Emulator">
        <optional name="JSR172" version="1.0" displayname="J2ME Web Services" classpath="${platform.home}/lib/JSR172.jar" dependencies="" default="true"/>
        <optional name="OBEX" version="1.0" displayname="Object Exchange APIs" classpath="${platform.home}/lib/JSR82.jar" dependencies="" default="true"/>
        <optional name="JSR179" version="1.0" displayname="Location Based APIs" classpath="${platform.home}/lib/JSR179.jar" dependencies="" default="true"/>
        <optional name="JSR75" version="1.0" displayname="File Connection and PIM Optional Packages" classpath="${platform.home}/lib/JSR75.jar" dependencies="" default="true"/>
		<optional name="JSR226" version="1.0" displayname="MOBILE 2D Graphics" classpath="${platform.home}/lib/JSR226.jar" dependencies="" default="true"/>
        <optional name="WMA" version="2.0" displayname="Wireless Messaging API" classpath="${platform.home}/lib/wma20.jar" dependencies="" default="true"/>
        <optional name="JSR82" version="1.0" displayname="Java APIs for Bluetooth Wireless Technology" classpath="${platform.home}/lib/JSR82.jar" dependencies="" default="true"/>
        <optional name="JSR184" version="1.0" displayname="Mobile 3D Graphics Optional Package" classpath="${platform.home}/lib/JSR184.jar" dependencies="" default="true"/>
<profile name="MIDP" version="2.0" displayname="Mobile Information Device Profile" classpath="${platform.home}/lib/midp20.jar" dependencies="" default="true"/>
        <optional name="NOKIAUI" version="1.0" displayname="Nokia User Interface" classpath="${platform.home}/lib/JSR139.jar" dependencies="" default="true"/>
        <configuration name="CLDC" version="1.1" displayname="Connected Limited Device Configuration" classpath="${platform.home}/lib/JSR139.jar" dependencies="" default="true"/>
        <optional name="MMAPI" version="1.0" displayname="Mobile Media API" classpath="${platform.home}/lib/midp21.jar" dependencies="" default="true"/>
        <screen width="240" height="320" bitDepth="12" isColor="true" isTouch="false"/>
    </device>
    <device name="S60Device" description="S60Device">
        ...
    </device>
</platform>

You should use these new libraries with caution as you have added jars that could have parts which aren’t compatible with the S60 3rd Edition FP1 Java ME execution environment. This is the case of the midp21.jar used for the MMAPI.

If you want you could also update the corresponding documentation setting the attribute docpath of the element platform in the Java ME platform configuration XML file (this property is not set in the above example).

Once this has been done, go to your Project’s Platform Properties window and watch the results:

Netbeans Project Platform Properties window for S60 3rd Edition FP1 for Symbian OS with selectable optional packages

Netbeans Project Platform Properties window for S60 3rd Edition FP1 for Symbian OS with selectable optional packages

Now you will be able to select the optional packages that you need. I have tested some applications built with this modified platform and seems to work well on both emulators and real devices, but the truth is that I have not done an extensive testing with all the APIs.

If you have any problems and want help or if you know a more stylish way of solving this inconvenience, let me know.

August 4, 2009

Surpassing JMUnit CLDC 1.1 TestSuite execution barrier on real devices

Filed under: Java ME, Mobility — Tags: , , , — Francisco Benitez Leon @ 8:07 pm

If you have developed Java ME mobile applications and you have used JMUnit for unit testing (which I strongly recommend), you would probably have noticed that TestSuites can’t be executed on some real devices (as Nokia® or Motorola® mobiles) and simulators/emulators (as Symbian 3rd Editon FP1 and FP2 or Java ME SDK) . This is due to the fact that MIDlets can’t create other MIDlets for security reasons (as stated in JSR118 only the application management software can do this), so if you try it you will get a SecurityException.

As explained in JMUnit manual section 3.1, the problem is that TestCase and TestSuite extends Test, which extends Assertion, which extends MIDlet =). So with any TestCase that you add to your TestSuite (which is already a MIDlet) you are adding another MIDlet and that’s why you would get a SecurityException when executing your TestSuite. To avoid this you will have to modify JMUnit source code and break this inheritance chain.

Breaking JMUnit inheritance chain (MIDlet dependency)

The process to break the chain is really easy: eliminate MIDlet from the inheritance chain, pass a MIDlet reference (midletRef) to whichever classes that use MIDlet’s methods and substitute these methods invocations for midletRef.method(). There’s one step more after breaking the chain as there is another class that uses MIDlet via Test, GuiListener has to be modified too.

I have complete this process in a project called JMUnit Revised. You could take a deep look at the process followed to modify JMUnit1.2.1 CLDC1.1 sources, download a patch and consult the usage at JMUnit Revised project’s page at my personal site. After creating a jar with the patched JMUnit1.2.1 CLDC1.1 sources and following the usage instructions you will be able to run your TestSuites on most real devices and simulators/emulators.

Now keep up happy testing! ;)

The Silver is the New Black Theme. Get a free blog at WordPress.com

Follow

Get every new post delivered to your Inbox.