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 = development on the Blackberry platform. After wading through some web pages 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.
Java Required
In order to develop using the Blackberry JDE you must first have installed the Sun Java Development Kit (JDK) (more than just the JRE). This package will give you access to the java compiler which the Blackberry JDE requires.
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.5.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.
Setting up the PATH
In order to run the Java compiler, JDE requires it be in the system PATH. 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\Java\jdk1.x.x_yy\bin;C:\Program Files\Research In Motion\BlackBerry JDE 4.x.x\bin (make sure you have the semi-colon at the front). Click Ok, then Ok again and finally one last time. You will have to check for the relevant version numbers on your own computer to fill in above.
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. Windows Firewall may ask if you want to allow JDE to access the Internet; I let it so I don’t know if it will work if blocked. 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 HelloWorldDemo sample. First thing you must do it set HelloWorldDemo 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 HelloWorldDemo (formerly 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 8300 Curve in its default configuration. Click the menu key and find HelloWorldDemo 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. I have also created a Blackberry API UI reference with screenshots and sample code.
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 in Project… 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 (everything below the package com.sample line) 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.
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!



February 21, 2008 - 3:06 pm
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!
March 4, 2008 - 8:33 pm
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.
March 7, 2008 - 8:45 pm
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!
March 13, 2008 - 4:57 am
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
March 14, 2008 - 11:31 pm
Navneet- Please make sure you set up JDK bin in the environment variable Path.
March 24, 2008 - 7:05 pm
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.
April 24, 2008 - 1:28 pm
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?
April 24, 2008 - 3:12 pm
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?
May 7, 2008 - 9:43 am
I have exatly same problem. Please help. ResourceBandle seems to be involved
May 12, 2008 - 4:30 pm
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.
May 13, 2008 - 12:03 am
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.
June 9, 2008 - 5:23 pm
Good post, esp the path seems a recurring issue.
And thanks Darren, I needed that last hint. Fighting with the obvious.
August 15, 2008 - 10:33 am
I just finished updating this for Blackberry JDE v4.5.0 which has a few differences. I moved the PATH section right after the Installation section since as was pointed out by a few people it is necessary for the JDE to run. In v4.5.0 there is no ResourceBundle and I didn’t have any trouble running HelloWorldDemo all by itself.
Thanks everyone!
September 7, 2008 - 4:30 am
Good tutorial for the newbies….:):) thanks
September 10, 2008 - 3:34 pm
A great tutorial! Thanks for taking the time to write it. For those who are wondering how to find the app on the simulator, I found it under “Downloads”.
September 20, 2008 - 3:14 am
Everything built and then I clicked Debug->GO and the Simulator opens, but there is no “HelloWorld” applicaiton… Hmm… Any ideas??
October 1, 2008 - 10:04 am
Thanks for the tutorial, everything worked fine and was able to get the application on my blackberry. One problem though, how do I delete it now? I tried Options->Advanced Options->Applications and it wasn’t in there, so I tried going into Modules and found it there, but there’s no delete option when I bring up the menu. Any ideas? Thanks!
October 1, 2008 - 10:55 am
Deletion can be done in two different ways.
The first is to use the Blackberry Desktop Manager. Go into the Application area and uncheck your app and it will be uninstalled.
The second method is to use the javaloader and the following command.
October 6, 2008 - 1:49 am
A very good site…Was looking for a site like this…it was very useful…Thanx a lot
October 15, 2008 - 5:12 am
Thnks….
Its very Helpful to me ..!
Once again thnks.. to “adamhewgill.com/devsushi” to provide this help..
bye..
October 15, 2008 - 5:33 am
Hi
Thanks for the tutorial…Its great!!!
But I have got one problem when i run my application the simulator gives me an error as JVM 545 error corrupt files…..
Can u tell me how to remove this!!!
October 16, 2008 - 2:55 pm
Hi i think is really usefull the code, could you help me, i need to send a string of character through the bluetooth, do you know how to do it?
October 17, 2008 - 6:56 am
Its a very good piece for sum1 like me ,I’ve just started working with this JDE..hope more information pours in….a little doubt why we need to set path in Environment variable…whereas while developing mobile application in sun java wtk..we don set the path….
November 7, 2008 - 5:57 am
Thanx a lot.. really helpful
November 19, 2008 - 5:27 pm
If you are having the source code not found error when running the hello world app. comment out the setTitle line in the constructor. The app will run fine then.
December 8, 2008 - 5:30 pm
I am running the debugger for the HelloWorld app but my debugger keeps saying “HelloWorldDemo.debug” file not found; HelloWorldDemo is one of the sample programs, but for some reason I can’t get the debugger to focus on the basic HelloWorld app. Also, the HelloWorld app does not appear in the applications folder of my Blackberry 8300 when I load it using the Desktop Manager, but I can see it listed as an application under the SETTINGS -> OPTIONS -> ADVANCEDED OPTIONS -> APPLICATIONS listing for my Blackberry. How can I get the Blackberry IDE to debug/simulate the simple HelloWorld app (and seemingly not the HelloWorldDemo app) and how can I run the application on my Blackberry? Any ideas will be awesome!!!
December 9, 2008 - 6:06 pm
Hi
I installed the jdk 1.5.0_16 which has jdk and jre . and then i downloaded the RIM which has the JDE. I have set the class path as mentioned . when I try to open the JDE, I get pop messagae “Error : could not find Java 2 Runtime Environment”.
Please advice
December 19, 2008 - 1:54 am
Great Steps,
December 23, 2008 - 7:00 pm
A great tutorial! Works beautifully!
Cheers!
January 13, 2009 - 9:57 am
Excellent articles.
Thanks a lot.
Your articles helped a lot.
can you tell me how to use the graphics class in the jde blackberry applications.
Thanks in advance.
February 9, 2009 - 3:37 pm
it’s a nice tutorial for begginners, Do you have more advanced tutorials like this one? or some java code links?
Thanks,
Edgar Torres
March 25, 2009 - 10:21 pm
Awesome! So far, the best tutorial i’ve found heheh… thanks a lot!
April 7, 2009 - 3:05 pm
Great tutorial! Thanks
May 1, 2009 - 7:47 am
Very Helpful for me……..
Thanks!!
May 7, 2009 - 7:21 am
Hi !
I got basic idea of how create new blackberry project & run it.
thanks!
May 31, 2009 - 2:48 pm
it’s goo to mention that the program is located under downloads folder and not under application folder.
June 3, 2009 - 9:02 am
This is the best tutorial whichever i read
June 28, 2009 - 12:38 pm
Thanks for this tutorial. It was a great help to figure out how to compile and run my first helloworld app on the Blackberry.
July 14, 2009 - 1:52 am
Hi,
Thanks a lot. It helps me great…
Once again Thanks….
July 15, 2009 - 4:47 am
Hi all, thanks fot this tutorial. My first HelloWorld works fine on the emulator, but if i send helloWorld.cod on my BB Bold 9000 with bluetooth on the folder memory card, when i click on the file the result is : is not possible to open file “memorycardHelloWorld.cod”.. must i create same packege or simply copy my helloWorld.con from workspace on my phone?
July 29, 2009 - 3:15 am
Good steps for any developer starting with Black Berry.
September 4, 2009 - 6:42 am
Hi,
Thank u so much this tutorial. was very helpful for me. u have done a great job.
Thanks
Som
September 6, 2009 - 10:35 pm
thanks for the tutorial :) it’s great
September 19, 2009 - 1:24 am
I am very thankful to the person who develop this tutorial.Going through this tutorial i have downloaded BB JDE and executed HelloWorld app successfully. I would like to know how to execute this HelloWorld app in out real Blackberry mobiles. If anyone knows please let me know..thanks in advance..
Regards,
Charitha Reddy
September 20, 2009 - 6:09 pm
Hi
I am very thankful to you.i have search different page but i got good solution from your tutorial
thanks
selvi
October 2, 2009 - 9:32 am
Thanks for the example. It really helps me alot. Well DONE !!!!
October 3, 2009 - 4:00 pm
It works perfectly with version 4.5.0, thanks so much.
October 3, 2009 - 10:03 pm
Hello Guys the turorial worked like a charm for me, but I have trouble uploading my .cod file to the device, I get a
“HRESULT error during open : 80040154 unable to open port”
error. Could someone help me out here? thanks
October 4, 2009 - 2:03 pm
I now have the solution, you have to install the cd that comes with the device, i think its a windows xp problem.
October 27, 2009 - 3:01 am
I have tried all the given direction but i am not able to see HelloWorldDemo application on the simulator screen.