站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Netbeans 专题Blackberry Development Using NetBeans Mobility

Blackberry Development Using NetBeans Mobility

摘要: With the RIM Blackberry JDE 4.1, you can now build Java ME applications for Blackberry devices using the NetBeans Mobility Pack 5.0. Here are the step-by-step instructions on how to get started

1. Download and install the NetBeans IDE. Then download and install the NetBeans Mobility Pack. Finally, download and install the RIM BlackBerry JDE 4.1. IDE. You will need this IDE because there are utilities distributed with the JDE and not with the simulators.

2. Add RIM as a custom emulator:

After this you will need to restart the NetBeans IDE.

3. Create a new project, for instance MobileApplication2, by selecting the Mobile Application option from the Mobile category.

4. Use File tab of the Explorer and open build.xml of the project. Add this fragment of code right before the </project>:

    <property name="rim.blackberry.home" location="C:\Program Files\Research In Motion\BlackBerry JDE 4.1.0"/>
    <property name="rim.blackberry.emulator" value="7250"/>
    <property name="rim.blackberry.jdwp.port" value="8000"/>

    <target name="post-jar">
        <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${dist.root.dir}"
executable="${rim.blackberry.home}/bin/rapc.exe"
failonerror="true" resolveExecutable="true">
          <arg value="import=${rim.blackberry.home}/lib/net_rim_api.jar"/>
          <arg value="codename=${name}"/>
          <arg value="-midlet"/>
          <arg value="jad=${dist.jad}"/>
          <arg value="${dist.jar}"/>
        </exec>
        <copy file="${name}.alx" todir="${dist.root.dir}"/>
    </target>
    <target name="run" depends="init,jar">
        <copy todir="${rim.blackberry.home}/simulator" verbose="true">
            <fileset dir="${dist.root.dir}">
                <include name="**/${name}.*"/>
            </fileset>
        </copy>
        <exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${rim.blackberry.home}/simulator"
executable="${rim.blackberry.home}/simulator/${rim.blackberry.emulator}.bat"
failonerror="true" resolveExecutable="true"/>
    </target>

    <target name="debug" depends="init,jar">
        <copy todir="${rim.blackberry.home}/simulator" verbose="true">
            <fileset dir="${dist.root.dir}">
                <include name="**/${name}.*"/>
            </fileset>
        </copy>
        <delete file="${preprocessed.dir}/.timestamp"/>
        <parallel>
            <property name="jpda.port" value="${rim.blackberry.jdwp.port}"/>
           <java jar="${rim.blackberry.home}/bin/JDWP.jar" fork="true" dir="${rim.blackberry.home}/bin">
              <jvmarg value="-Xmx128M"/>
           </java>

            <sequential>
                <sleep seconds="5"/>
                <antcall target="nbdebug"/>
            </sequential>
        </parallel>
    </target>

    <target name="post-clean">
        <echo>Post clean</echo>
        <delete>
            <fileset dir="${rim.blackberry.home}/simulator">
                <include name="**/${name}.*"/>
            </fileset>
        </delete>
    </target>
5. From the Files tab, create a new Empty file, called <name_of_the_project>.alx, and save it into your project folder (on the same level as build.xml!) with the following content. Change the names of course to reflect your application. This is a special file required by Blackberry devices to identify the application details.
<loader version="1.0">
    <application id="MobileApplication2">
        <name >
        </name>

        <description >
        </description>

        <version >
        </version>

        <vendor >
            MyCompany
        </vendor>

        <copyright >
            Copyright (c) 2005 MyCompany
        </copyright>

        <fileset Java="1.5">
            <directory >
                MyCompany
            </directory>

            <files >
                MobileApplication2.cod
            </files>
        </fileset>

    </application>

</loader>
6. At this point, you are ready to write code, build, run, execute and debug. If you use this code fragment to patch the build.xml file instead of the one in step 4, you can even set RIM execution/debug for particular project configurations. However, it has to be done in build.xml using this (Test is name of the configuration):
    <target name="init.rim.blackberry" depends="init">
        <condition property="rim.blackberry" value="true">
            <or>
                <equals arg1="Test" arg2="${config.active}"/>
            </or>
        </condition>
    </target>
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.


↑返回目录
前一篇: Asynchronous JAX-WS Web Service Client End-to-End Scenario
后一篇: Building and Running Java PathFinder with NetBeans