Getting started with Developing and Debugging blackberry apps: OS 7.1, JDE 7 and Javaloader.exe
When my Windows Phone died (Dell Venue Pro 8GB) I picked up a BlackBerry Bold 9900 as a replacement (couldn't find a decent non-blackberry keyboard to save my life!). This got me into Blackberry phone development (previous BB dev has consisted of WebWorks applications for Playbook).
After a couple of days of trying to build & debug a Blackberry app, I can see that the road is long and the tools not as polished as what Microsoft and Apple offer. Case in point: I wanted to debug a simple 'hello world' application on my phone and couldn't figure out how to get it to work until now. I'd like to pass along my findings.
Update: Most of the issues went away when I switched from JDE to the 'Blackberry plugin for eclipse'. If you want to pursue Blackberry OS development, go with Eclipse and you will be less disappointed.
References:
- Running your application on a smartphone [developer.blackberry.com]
- Shows the CORRECT syntax for javaloader on BB 7.1
- Installing the Blackberry JDE on 64-bit Windows [accella.net]
- Tools for BlackBerry Java Development [developer.blackberry.com]
Misleading, Unhelpful or out of date resources:
- How To Use Javaloader [supportforums.blackberry.com]
- About 3 minutes in it tells you to use the -u switch which does NOT work any more
- JavaLoader - Load/Remove applications from BlackBerry Device without using BlackBerry Desktop Manager [bbdevtips.blogspot.com]
- Also indicates that you should use the -u switch
- Using the Blackberry Javaloader [enduserguides.com]
- Shows incomplete examples
- Indicates that the -u option should be used
- Load cod file to BlackBerry using JavaLoader [inteist.com]
- Shows the even older -u=USB syntax which does not work anymore
- Testing applications on a BlackBerry device [docs.blackberry.com]
- This doc tells you that it is possible to debug on a device, but doesn't tell you HOW to do it or WHERE to go to find out how to do it.
Well, that took awhile...
Get started with JDE 7
- Downlaod & an Oracle JDK (version 6 or higher- I went with JDK 7 update 6 )
- Be sure to download the 32bit version! This is true even on x64 systems (JDE is x86 only)
- Downlad & Install the Blackberry JDE
- If you run into problems on Windows 7 x64, consult this article [accella.net]
- For best results, be sure to install the appropriate version of the Blackberry Device OS + Blackberry Desktop from this site.
- You will want to search for your mobile Carrier in the list.
- Open the JDE (From Start -> All Programs)
- Create a new Workspace by going to File -> New Workspace...
- Give the workspace a name and location on the file system
- Right-click on the name of the workspace and select Create new Project...
Then give it a Name and click ok
- To create an actual Source code file, Right click on the project name and select Create new File in Project
Then give the file a name with a .java extension
Note: The Filename *must* match the classname. In this case I'm borrowing some sample code that has a classname of HTTPFirstAvailable.
- Enter your source code in the .java file that you just created. I used sample networking code from this blackberry page
- Select the Build menu and click the Build button.
- If all goes well you should see Build Complete appear in the bottom status-window.
- You have just successfully build a .cod file (binary for BlackBerry phones)
Load your app on the Device
- Plugin your BlackBerry via USB
- If the Blackberry Desktop manager prompts for a password, just say 'No'.
- Open up a Dos Command Prompt and cd into your BlackBerry JDK folder. For me (OS 7.1) this path is:
- C:\Program Files (x86)\Research In Motion\BlackBerry JDE 7.1.0\bin
- From within the DOS prompt, execute the following command (adapt to your .cod path):
- javaloader.exe load "c:\path\to\myexecutable.cod"
For clarity, here is a screen-cap of what the transfer process looks like:
Start Debugging
At this point we are almost ready to debug! Just a few more steps and we can step through the code.
- Within the JDE Environment, select Debug -> Attach to -> Handheld -> Device PIN
- If you have multiple devices connected you should be able to pick which one to connect to. I only have one device connected in this example.
- If you get an error that says something like "No debug information found for module 'net_rim_cldc'. Please ensure that you have installed the simulator package that matches the handheld code you are attempting to debug.", don't panic.
Apparently this happens if you don't have an exact software match between what is installed on the PC and the BB. I am still able to debug when i see this error. - From within JDE, set a breakpoint on a line of code (right-click -> Set breakpoint at cursor)
- From the Device run the program (Should be placed on the home screen if the javaloader step was successful)
- The break-point should be hit, and you'll be able to step through the code and investigate variable states as you please.
Congratulations! You are all setup to create and Debug Blackberry OS 7.1 applications on real BB device. :)
Here's what the debugger window looks like in JDE 7: