当前位置: 代码迷 >> BlackBerry >> NetBeans Mobility 开发 Blackberry 的环境设立
  详细解决方案

NetBeans Mobility 开发 Blackberry 的环境设立

热度:3501   发布时间:2013-02-26 00:00:00.0
NetBeans Mobility 开发 Blackberry 的环境设置

我使用的是NetBeans6.0以及BlackBerry JDE 4.3.0。

1,通过以下步骤添加BlackBerry模拟器

  • 从顶部的导航栏选择 Tools > Java Platform Manager。
  • 单击 Add Platform 按钮。
  • 选择 Custom Java Micro Edition Platform Emulator 单选按钮并单击 Next 按钮。
  • Platform Home 应该是 JDE 安装目录(C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0),在 Platform Name 和 Device Name 中可以输入你想要的任何名称。不要更改其他内容,然后按 Next。
  • 将会转到“Bootsrap Libraries”面板并看见一个很长的 jar 文件列表,将该列表中除 net_rim_api.jar 之外的文件全部选中,然后按 Remove。
  • 单击 Sources and JavaDoc 旁边的 Add at JavaDoc 并键入或浏览到:C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\docs\api\,然后选择 Finish 按钮。
  • 重启NetBeans

    3. 通过从 Mobile 类别选择 Mobile Application 选项可以创建新项目。

    4. 使用 Explorer 的 File 选项卡并打开项目的 build.xml 文件。将以下代码片段添加到 </project> 之前:

    前两行分别为BlackBerry的安装目录以及模拟器型号,请先确认目录是否正确,并且在对应目录下有对应的模拟器。

    ????<property?name="rim.blackberry.home"?location="C:Program?FilesResearch?In?MotionBlackBerry?JDE?4.3.0"/>
    ????
    <property?name="rim.blackberry.emulator"?value="8120"/>
    ????
    <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. 从 Files 选项卡中创建一个名为 <name_of_the_project>.alx 的新 Empty 文件,并使其携带以下内容存入项目文件夹(与 build.xml 所在的目录同级!)。当然,可以更改名称来反应您的应用程序。这是 Blackberry 设备识别应用程序详细信息所需的特殊文件。

    <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. 现在,您已经准备完毕,可以编写代码、构建、运行、执行和调试了。

  •   相关解决方案