corner imagecorner image
FeaturesPluginsDocs & SupportCommunityPartners

Blackberry Development Using NetBeans Mobility Pack 5.5

With the RIM Blackberry JDE 4.1, you can now build Java ME applications for Blackberry devices using NetBeans Mobility Pack for CLDC/MIDP 5.5.

Requirements

Before you begin, you need to install the following software on your computer:

Setting Up for BlackBerry Development

To set up your NetBeans IDE for Blackberry development, you need to add the Blackberry JDE as a custom platform emulator because there are utilities distributed with the JDE that are not distributed with its emulators.

To do this, you perform three steps:

  1. Add the RIM Blackberry JDE as a custom emulator
  2. Create a Blackberry project
  3. Set the Blackberry as the default device emulator

Adding the RIM Blackberry JDE as a Custom Emulator

To begin, you must register the RIM Blackberry emulator using the Java Platform Manager:

  1. Select Tools > Java Platform Manager from the top navigation bar.
  2. Click the Add Platform button.
  3. Select Custom Java Micro Edition Platform Emulator. Click Next.
  4. The Platform Home should be JDE installation directory (C:\Program Files\Research In Motion\BlackBerry JDE 4.1.0).
  5. You can enter whatever you want for the Platform Name.
  6. Set Device Name to one of the supported devices: 7100g, 7100r, 7100t, 7100v, 7100x, 7250, 7290, 7520
  7. Keep the Preverify Command as it is.
  8. Modify the Execution and Debugger Commands as shown:
    • Execution Command: cmd /C "cd /D {platformhome}{/}simulator&{device}"
    • Debugger Command: cmd /C "cd /D {platformhome}{/}bin&jdwp"
    Click Next.
  9. The Bootstrap Libraries panel displays a long list of jar files. Select all of the listed files except net_rim_api.jar and click Remove. Click Next.
    Note: If the net_rim_api.jar is not in the list, Click the Add button, and type in or navigate to C:\Program Files\Research In Motion\blackberry JDE 4.1.0\lib\net_rim_api.jar and click Open.
    Then click Next.
  10. In the Sources and JavaDoc panel, click the Add button next to the JavaDoc window and type in or navigate to: C:\Program Files\Research In Motion\BlackBerry JDE 4.1.0\docs\api\. The Java Platform Manager should look like the following graphic:

    Java Platform Manager dialog with commands edited

    Click Finish, then click Close.

Creating a Blackberry Project

Next, you create a project for your application:

  1. Choose File > New Project.
  2. Under Categories, choose Mobile. Under Projects, choose Mobile Application. click Next.
  3. Give the project a name, for example MobileApplication2.
    If you do not want a sample MIDlet created for your project, uncheck the "Create Hello MIDlet" check box.
  4. Click Finish to create the Project.
  5. Select the Files Tab in the Explorer window and open the project's build.xml file. Add this fragment of code right before the </project> tag at the bottom of the file:
  6.     <target name="pre-jar">
            <available file="${platform.home}/bin/rapc.exe" property="do.rapc"/>
            <condition property="jpda.port" value="8000">
                <isset property="do.rapc"/>
            </condition>
        </target>
        <target name="post-jar" if="do.rapc">
            <exec dir="${platform.home}/simulator" executable="${platform.home}/bin/rapc.exe" failonerror="true">
                <arg value="import=${platform.bootclasspath}"/>
                <arg value="codename=${name}"/>
                <arg value="-midlet"/>
                <arg value="jad=${basedir}/${dist.dir}/${dist.jad}"/>
                <arg value="${basedir}/${dist.dir}/${dist.jar}"/>
            </exec>
        </target>
        <target name="post-clean">
            <delete failonerror="false">
                <fileset dir="${platform.home}/simulator">
                    <include name="**/${name}.*"/>
                </fileset>
            </delete>
        </target>
    
  7. If you would like to extend net.rim.device.api.ui.UiApplication instead of standard MIDlets in your project, then:

    • Remove the highlighted argument line <arg value="-midlet"/> from the build.xml script above.
    • Ignore the warnings in Project Properties / Application Descriptor / MIDlets category when adding a class that does not extend MIDlet.

    The code in the Source Editor window should look like this:

    Screenshot of the IDE with the build.xml file selected in the Files window and code entered into the Source Editor window.

Set the Blackberry as the Default Device Emulator

Now you're ready to set the default configuration to emulate a Blackberry device:

  1. Right-click on the project and choose Properties.
  2. In the Platform Properties:
    • Choose Blackberry 4.1 from the Emulator Platform drop-down menu.
    • Choose the Blackberry device emulator from the Device drop-down menu.

    Platform Properties window with Blackberry device set up as default emulator

At this point, you are ready to write code, build, run, execute, and debug your MIDlet for the BlackBerry.

In your project, you still have the freedom to use various platforms for different project configurations. You can work around the limitation of one device per one custom platform by repeating the steps in Adding RIM as a Custom Emulator with an alternative platform name.

Note: Once you build your project and the emulator launches, you will need to scroll to the icon for your application, which will be on the main phone screen when the emulator comes up. You can use the arrow keys or click the scroll wheel on the emulator image to navigate to your application icon.


Bookmark this page

del.icio.us furl simpy slashdot technorati digg