Getting started with the Blackberry Java Development Environment (JDE)
Recently I became frustrated with the state of free games for the Blackberry platform. Brickbreaker is really hard and choppy on the newer devices so I decided to do something about it. I also have a Blackberry Pearl just sitting at home since my recent upgrade to the Blackberry Curve. So frustration + extra device + time = developement on the Blackberry platform. After wading through some webpages on the developer site and running into more than one snag I decided to document to process in tutorial form. I hope this helps you get starting with the Blackberry JDE. Please feel free to drop questions in the comments or to email me at ahewgill@gmail.com.
Installation
The first step is to install the Blackberry Java Development Environment (JDE) available on from the Blackberry Developer website. (As of this writing the latest version is 4.3.0). You have to register for an account and verify via email in order to download the software which is very annoying. It took them 24 hours to send me the verification link so that I could sign in and begin the download. It is best to download the full JDE rather than the individual pieces in my opinion but this is up to you and your bandwidth constraints.
Running a few samples
Once you have the JDE installed it is time to try out a few of the samples provided. First open the editor by clicking Start -> Programs -> Research in Motion -> Blackberry JDE 4.x.x -> JDE. Once in the editor click File -> Open Workspace… and browse to C:\Program Files\Research in Motion\Blackberry JDE 4.x.x\samples and select samples.jdw.
Let’s run the HelloWorld sample. First thing you must do it set HelloWorld to be the only active project. Click Project -> Set Active Projects… and then in the dialog that appears click Clear All and then check off com_rim_helloworld and click Ok. You are now ready to build and run the project. Click Debug -> Go to build the code and run the simulator (can take time to load so be patient).
The first thing you will notice is that you’re presented with a Blackberry 8120 Pearl in its default configuration. Click the menu key and find HelloWorld in the application list. Click the trackball to run it, voila! To exit the application click the menu key and then click the close option. Simple right! I encourage you to take a look through the code of the various demos at some point to become familiar with the Blackberry APIs.
In the editor click File -> Close Workspace and then close any code windows you might have open on the right before continuing.
Creating your own HelloWorld
Now that you know how to use the editor and run an application it is time to start your first program. I’m going to give you the code but the idea of this section is to learn how to create a new workspace, project, and code file. Click File -> New Workspace… and then give your program a name like MyHelloWorld. In the second box add MyHelloWorld to the end of the creation path leaving off the last backslash. Click Ok and then Yes to the directory creation question. You now have a new workspace in which to put your project.
To create the project simply click Project -> Create New Project… and enter the project name (eg HelloWorld) into the first box. This time you don’t have to mess with the directory, just click Ok.
Now it is time to add a code file to your empty project. On the left click the HelloWorld project in the Files tree view. Now click Project -> Create New File and enter a file name (eg HelloWorld.java) into the first box. In the second box we need to add at least one directory because Java likes to organize things into packages. Add \com\sample to the end of the second box and note that the automatically generated code has the line package com.sample;. You’ll notice this type of thing throughout the Java APIs, this is how classes are organized.
Now that we have a code file it is time to add some code. Replace the tiny little empty class stub with the follow code (I stole this directly from the HelloWorld sample we ran above).
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
/*
* BlackBerry applications that provide a user interface
* must extend UiApplication.
*/
public class HelloWorld extends UiApplication
{
public static void main(String[] args)
{
//create a new instance of the application
//and start the application on the event thread
HelloWorld theApp = new HelloWorld();
theApp.enterEventDispatcher();
}
public HelloWorld()
{
//display a new screen
pushScreen(new HelloWorldScreen());
}
}
//create a new screen that extends MainScreen, which provides
//default standard behavior for BlackBerry applications
final class HelloWorldScreen extends MainScreen
{
public HelloWorldScreen()
{
//invoke the MainScreen constructor
super();
//add a title to the screen
LabelField title = new LabelField("HelloWorld Sample",
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
//add the text "Hello World!" to the screen
add(new RichTextField("Hello World!"));
}
//override the onClose() method to display a dialog box to the user
//with "Goodbye!" when the application is closed
public boolean onClose()
{
Dialog.alert("Goodbye!");
System.exit(0);
return true;
}
}
Click Build -> Build (or hit F7) to make sure it compiles with no errors. Any syntax errors or other messages will appear in the bottom Build window so make sure to look there before assuming everything worked. Now hit Debug -> Go to run the code in the Blackberry simulator.
Setting up the PATH
In order to run the command line tools it is easiest to put the JDE \bin directory into your PATH environment variable. To do this right click on My Computer and click Properties. Now click the Advanced tab and then the Environment Variables button. In the system variables (lower) part find and select the PATH variable and then click the Edit button. Now at the very end of the string add ;C:\Program Files\Research In Motion\BlackBerry JDE 4.3.0\bin (make sure you have the semi-colon at the front). Click Ok, then Ok again and finally one last time.
Installation on a physical device
Once you have an application and have run the simulator a few times you might get the desire to install your app on an actual device. It is fairly easy to do this once you have setup the PATH variable. Open a command window by clicking Start -> Run… type cmd and hit enter. In the little black window go to the location of your application and find the .cod file. Make sure you’ve connected your device with the USB cable and then run the following command.
javaloader -usb load HelloWorld.cod
You’re handset will go white with a spinning hour glass for a few seconds and then back to normal. You will now see the application icon installed on the device. Congratulations you are now a Blackberry developer!
Categories
Recent
- Blackberry JDE API - User Interface Field Reference
- Getting started with the Blackberry Java Development Environment (JDE)
- ASP.Net DropDownList annoyance
- Mambo to the beat of the internet
- ASP.Net has 9 to 5 appeal
- ASP.Net CheckBoxes should be able to have values
- Time to take a look at Python I guess
- Country list formatted for MySQL import
- Kinetic Typography: typographic treatment of an audio sample
- MSN Video Sucks
- Five things about me
- ASP.Net file download protection through authentication
- ASP.Net Dynamic Controls (Part 4)
- Rollyo Comment Spam
- ASP.Net Dynamic Controls (Part 3)



Great tutorial! I’ve been looking for a step by step guide myself. When setting up my project my steps were a little bit different, perhaps I have a different version (4.3.0.1r). None the less, I was able to make a simple program. Thanks!
I’m afraid this does not quite work. Trying Debug -> Go does start the simulator but when you click on the Hello World icon you get the error “source code is not available” for a file called NoSuchFile.java.
This worked great for me, thanks!
I just wish the code/run/code cycle were quicker. It’s a pain to have to close down the simulator before changing the code, and it’s a pain to have to start the simulator and navigate to the application to run it on the simulator after recompiling.
Is there a quicker way? I wish I could keep the simulator running, make code changes, and then just hit F5 or something to have the code built and run immediately on the simulator.
Thanks!
Hello great tutorial but as i do debug->go it gives me I/O Error: CreateProcess: javac -source 1.3 -target 1.1 -g -O -d C:\DOCUME~1\navneet\LOCALS~1\Temp\rapc_275bcb6a.dir -bootclasspath ..\..\lib\net_rim_api.jar -classpath ..\..\lib\net_rim_api.jar “C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\Myhelloworld\com\sample\HelloWorld.java” error=2
Error while building project
This error please let me know what is the problem
Navneet- Please make sure you set up JDK bin in the environment variable Path.
The CreateProcess error is caused by your env path. Make sure you have your JDK’s bin directory in your path. (Control Panels->System->Advance->Enviroment add your JDK/bin path to PATH)
That fixed it for me. Hope this helps.
I’m having the same problem as Gary. I click Debug –> Go and the BB Simulator comes up. Eventually I click the Hello World application, and the JDE reports an error: Uncaught exception thrown - MissingResourceException - C:\NoSuchFile.java” I checked the RIM directory, and that java file doesn’t exist, so I think I set something up incorrectly.
Any thoughts?
Quick Update: I have a little more information about the problem. It’s the HelloWorldScreen class constructor, setTitle method call that’s failing. If I step through the code, it runs up to that line and then blows up. If I try to get the definition of setTitle(), it tells me:
File ‘C:\ABS10\Components\JavaDevice\Platform\4.3.0\Lynx\runtime\net\rim\device\api\ui\container\MainScreen.java’ not found.
I can’t find that file anywhere in the file system.
Any ideas?
I have exatly same problem. Please help. ResourceBandle seems to be involved
I’m having the same problem as gary/mk/paul.
BUT, the samples seem to work if instead of setting only the “com_rim_helloworld” as the active project (Project -> Set Active Projects…), I “select all” and then do a “debug -> go”.
I’m not sure how it helps me, but I thought I’d throw that out there.
Thanks for posting this. I found you also need to activate the Resource project, “com_rim_demores__en”, to get the app to run in the simlator. Prior I was also getting the “Resource” error in the debugger.
Good post, esp the path seems a recurring issue.
And thanks Darren, I needed that last hint. Fighting with the obvious.