A few years ago I posted (in the former BlackBerry Java Developers forum) steps for getting the HelloWorld demo to compile and debug in Eclipse using "etaras anttask." Since etaras no longer exists, and I haven't (yet) become happy with the Eclipse Plugin, I have rewritten those steps for using the bb-ant-tools and updated and tested the steps for compatibility with Eclipse 3.4.1 and BlackBerry JDE 4.3.0. You should also be able to use newer JDE's as well.
Prerequisites
1. You have installed Eclipse 3.4.1 or later.
2. You have installed the BlackBerry JDE 4.3.0. Find it at http://na.blackberry.com/eng/developers/javaappdev/devtools.jsp
3. You have installed Sun's JDK 5.0. Find it at http://java.sun.com/j2se/1.5.0/download.jsp
Extend the Sun JRE
1. Start Eclipse .
2. In the menubar, click Window > Preferences.
3. Select Java > Installed JREs.
4. Click Add.
5. Select Standard VM.
6. JRE home = the location of your Sun JRE. For example: C:/Java/jdk1.5.0_11/jre
JRE name = jre_1.5.0+rim4.3.0 (or whatever you like)
7. Click Add External JARs.
8. Browse to the lib folder of you installation of the BlackBerry JDE. For example: C:/Program Files/Research In Motion/BlackBerry JDE 4.3.0/lib
9. Select net_rim_api.jar.
10. Click Open.
Add the RIM API documentation
1. Still in the Add JRE window, expand the net_rim_api.jar file.
2. Select Javadoc location.
3. Click Javadoc Location... button.
4. Click Browse.
5. Navigate to the docs/api folder of your BlackBerry JDE installation. For example: C:/Program Files/Research In Motion/BlackBerry JDE 4.3.0/docs/api
6. Click OK. Click Finish. Click OK.
Create a new Helloworld Java Project
1. On the taskbar, click File > New > Project.
2. Select Java Project and click Next.
3. Project name = Helloworld
JRE = Use the specific JRE that you created above.
4. Click Finish.
Add the bb-ant-tools jar to the project
1. Download the bb-ant-tools.jar from http://bb-ant-tools.sourceforge.net.
2. In Eclipse 's Package Explorer, right-click to highlight the Helloworld project folder.
3. Click New > Folder.
4. Folder name = lib.
5. Click Finish.
6. Copy bb-ant-tools.jar into Eclipse in the new lib folder.
7. Expand the lib folder and right-click bb-ant-tools.jar.
8. Click Build Path > Add to Build Path.
Copy Helloworld into the project
1. In Eclipse 's Package Explorer, expand the Helloworld project folder.
2. There should already be a src folder. If not, right-click the project folder, select New > Source Folder, name it src, click Finish.
3. Create an output folder. Right-click the project folder, select New > Folder, name it output, click Finish.
4. Right-click on the src folder.
5. Click New > Package.
6. Name = com.rim.samples.device.helloworld
7. Click OK.
8. From the Windows desktop, open a Windows Explorer and navigate to the BlackBerry JDE's helloworld project. For example: C:/Program Files/Research In Motion/BlackBerry JDE 4.3.0/samples/com/rim/samples/device/helloworld
9. Copy the HelloWorld.java file from Windows Explorer into Eclipse under the Helloworld project's com.rim.samples.device.helloworld package. HelloWorld.java will indicate a compile error because the HelloWorldResResource interface is generated on-the-fly by the BlackBerry RAPC compiler.
10. In Eclipse 's Package Explorer, right-click on the Helloworld project folder.
9. click New > Folder.
11. Folder name = resource.
12. Click Finish.
13. Copy the files from the BlackBerry JDE's helloworld project img folder into the new resource folder in Eclipse .
14. Copy all seven or so files with names beginning HelloWorldRes from the resource folder in the Windows Explorer (at the same level as the helloworld folder) into the new resource folder in Eclipse .
Create the build.xml ant task
1. In Eclipse 's Package Explorer, right-click the Helloworld project folder.
2. Click New > File.
3. File name = build.xml.
4. Click Finish.
5. Put the XML at the end of this file as the content of the build.xml. Be sure to modify any file paths appropriately. Modify the bat file referenced by the simulate task to refer to the device that you wish to simulate. For documentation on the elements of this ant task see http://bb-ant-tools.sourceforge.net.
6. Right-click build.xml.
7. Click Run As > Ant Build...
8. Under the Targets tab, check only buildRIM.
9. Click Run.
10. The message BUILD SUCCESSFUL should appear in Eclipse 's console output.
11. Right-click the output folder in the Helloworld project and click Refresh. The generated BlackBerry JDE files should appear.
Simulate the Helloworld project
1. In Eclipse 's Package Explorer, right-click build.xml.
2. Click Run As > Ant Build...
3. Under the Targets tab, check only simulate.
4. Click Run.
Note: The BlackBerry executable files are deployed under the BlackBerry JDE's simulator folder. For example: C:/Program Files/Research In Motion/BlackBerry JDE 4.3.0/simulator. You can run the clean.bat file in this folder to delete all of the files deployed since the JDK was installed.
Debug the Helloworld project
1. In Eclipse 's Package Explorer, right-click build.xml.
2. Click Run As > Ant Build...
3. Under the Targets tab, check only debug.
4. Click Run.
5. The RIM Remote Debug Server will launch.
6. In Eclipse 's Package Explorer, right-click the Helloworld project folder.
7. Click Debug As > Debug Configurations.
8. Highlight Remote Java Application.
9. Click New.
10. Click Debug.
Note: According to the BlackBerry Application Developer Guide if you see the message "Failed to connect to remove VM. Connection timed out", increase the Debugger Timeout in Eclipse under Windows > Preferences > Java > Debug > Communication.
build.xml content:
(Modify any file paths appropriately. Modify the bat file referenced by the simulate task to refer to the device that you wish to simulate. For documentation on the elements of this ant task see http://bb-ant-tools.sourceforge.net. )
<?xml version="1.0" encoding="UTF-8"?>
<project name="${description}" default="buildRIM" basedir=".">
<taskdef
resource="bb-ant-defs.xml"
classpath="lib/bb-ant-tools.jar" />
<property name="jdehome"
value="C:/Program Files/Research In Motion/BlackBerry JDE 4.3.0" />
<property name="simulator" value="${jdehome}/simulator" />
<property name="bin" value="${jdehome}/bin" />
<target name="debug" depends="deploy" description="Builds, Deploys Project and Launches Remote Debug Server">
<exec executable="cmd.exe" dir="${bin}" spawn="true">
<arg value="/c" />
<arg value="jdwp.bat" />
</exec>
</target>
<target name="simulate" depends="deploy" description="Builds, Deploys Project and Launches Simulator">
<exec executable="cmd.exe" dir="${simulator}" spawn="true">
<arg value="/c" />
<arg value="8130.bat" />
</exec>
</target>
<target name="deploy" depends="buildRIM" description="Builds and Deploys Project">
<copy todir="${simulator}" overwrite="true">
<fileset dir="output">
<include name="*.cod" />
<include name="*.debug" />
<include name="*.csl" />
<include name="*.cso" />
</fileset>
</copy>
</target>
<target name="buildRIM" description="Builds Project">
<rapc jdehome="${jdehome}"
jdkhome="C:/Program Files/Java/jdk1.5.0_11"
destdir="output"
output="HelloWorld"
quiet="false">
<jdp type="cldc"
title="Hello World Demo"
vendor="Vendor=Research In Motion Ltd."
version="Version=0.9"
description="HelloWorld Application"
arguments=""
systemmodule="false"
runonstartup="false"
startuptier="7"
ribbonposition="0"
icon="../resource/helloworld_jde.png">
</jdp>
<src>
<fileset dir=".">
<include name="src/**/*.java" />
<include name="resource/**/*.*" />
</fileset>
</src>
</rapc>
</target>
</project>