Saturday, March 20, 2010

Integrating BlackBerry Emulator with the NetBeans IDE

By reading this you can be able to integrate BlackBerry Emulator 8530, 9500, 9530 to the NetBeans IDE. Emulator 8530 can also be used for 8520.

There is a considerable market share of BlackBerry Hand-held devices through out the globe, so I think developing applications for BlackBerry Devices is an interesting thing for developers. Now many mobile vendors have started giving support to Java as well, as there is a huge market for Java applications. They are popular because they are cross-platform. And I think NetBeans is a quiet old and so much matured IDE for Java Development, which makes it very popular among the developers.

Though I have a few years of experience in Java development, I am very new to Mobile application development. As per requirement I had to develop mobile application in Java and at start I found it very difficult to set up a development environment. There are many links, forums and blogs are available with lot of information which is sometimes very useful and sometimes not. So I have decided to share my experience with the new BlackBerry/NetBeans developers. I hope it will help you all. Instead of writing so much I believe in step by step guide. Now here we go….

Integrating BlackBerry Emulator 9500 with the NetBeans IDE:

1. Download and install BlackBerry JDE 4.7.0. After installation path will look like as follows:
C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0
2. Download NetBeans IDE. I have download and installed the NetBeans IDE 6.8.
3. Open a new text file and paste the XML file from the following link.

Note: You will need to copy XML code from the link below as I am not able to post the edited XML code on this blog. I hope you will do the changes in it as I will specify below.

You will need to edit this XML file properly
Instead of 8800, you will need to place the 9500. So just find 8800 and replace it with 9500. 

Please also find and change the following:

platform name="BlackBerry_JDE_470" 
               home="C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0" 
device name="9500" 
4. Name this XML file as RIM_BB_9500.xml and place it to the following path:
C:\Documents and Settings\local-user-name\.netbeans\6.8\config\Services\Platforms\org-netbeans-api-java-Platform
5. Start NetBeans IDE. Note: If your NetBeans is already running, then please close it and again restart it.
6. In your NetBeans IDE, right Click on your project in the Projects tab, then Properties, which will open a window with your application name as a title.
7. Then select RIM_BB_9500 from the drop down list in the Emulator Platforms.
8. Select Device 9500 from the drop down list.
9. Click OK. Note: You may require adding the libraries by checking the check boxes in the optional package area, as per your projects requirement.
10. That’s it, run your application, BlackBerry emulator for device 9500 will be opened.

Special Note: Integrating BlackBerry Emulator 9530 with the NetBeans IDE

You can also use the Emulator 9530 using the same file above. Only you will need to perform few simple steps as below:
a. Keep above XML i.e. RIM_BB_9500 file as it is, just copy it and paste it in the same directory as mentioned in the step 4 above, and rename it as RIM_BB_9530.xml.
b. Open the newly created file, then Find all the occurrences of 9500 and Replace them all with 9530.
c. Save it, and that’s it. Another Emulator is ready for you.

Integrating BlackBerry Emulator 8530 with the NetBeans IDE:

I have a BlackBerry 8520 Curve Smart Phone, for which I had to develop a commercial application. It is best idea to develop and execute it on emulators available. But exact emulator for 8520 is not available into the simulator folder of the JDE. But as I mentioned above, we can use BlackBerry 8530 simulator. Here is the important step which I have discovered [may be bit of exaggeration but it is true, as I didn’t find this anywhere, so sharing with you.]

11. Download and install BlackBerry Smart phone Simulators 5.0.0. After installation, path will look like as follows:
C:\Program Files\Research In Motion\BlackBerry Smartphone Simulators 5.0.0
12. Then copy the folder (8530) from above path, and paste it into your simulator folder of the JDE. IE copy this folder to the following path:
C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0\simulator
13. Then again you have to do, not exactly the same but something similar as mentioned in the special note above like:
a. Keep above XML i.e. RIM_BB_9500 file as it is, just copy it and paste it in the same directory as mentioned in the step 4 above, and rename it as RIM_BB_8530.xml.
b. This step has been changed a bit. 

Instead of device name="9500" & description="9500", Do both 8530.
Or if you have copied XML directly from the link I have provided, then there will be
device name="8800" description="8800", you should edit them to 8530.

Then do the final change which is very important. Find the statement
runcmd="cmd /C "cd /D {platformhome}{/}simulator&{device}""

And replace it with
runcmd="cmd /C "cd /D {platformhome}{/}simulator{/} (8530)&{device}""

Here you go… Now you have an emulator platform ready to execute your Java Mobile applications.
I could do all the steps and show it here the actual edited XML file, but due to some reason this site wont allow me to post XML and HTML codes. I tried doing so but couldn't succeeded to post the XML files. Sorry about that. But I am sure you can do those simple editing stuff as I mentioned above.

In Short, you will need to edit carefully the following tags and their respective Properties in the XML file:
platform Tag: name, home, displayname, runcmd.
Device Tag: name, description. 
As now, you have integrated the Emulator with the NetBeans IDE, now you have to perform few more steps to build
and run your project. For that please follow the steps below.

14. You will need to download the MEP client. Please go to the link, submit the required information and download bundle.

15. Unzip the bundle somewhere, I preferred C:\

16. In the NetBeans, Add mep_client_api.jar to your project as a supported Libraries & Resources. Please follow the steps below.
a. In the Projects tab, Right-Click on your project and select the Properties
b. Click Libraries & Resources
c. Click Add Jar/Zip
d. Browse to the location of the unzipped bundle and add the mep_client_api.jar. For example, I have unzipped the bundle to C:\ drive, and the path looks as


e. Click OK.
f. Click on the Files tab, just next to Projects tab and open the file under the nbproject directory.
g. Edit [or add if not present] the file.reference.mep_client_api.jar property to contain the fully qualified path name of the mep_client_api.jar file. For example,


Please use forward slashes [/]

17. Now, Click the Files tab and open the build.xml file. Now again as I am not able to post XML code here, you will need to copy it from the link below and add the code immediately before end of the </project> tag at the end of the file.

[From the link above, copy the XML code snippet from the point number 9.]

Note: For the emulator 8530, add / (8530) in front of {platform.home}/simulator wherever it is found in the XML code above; so that it will look like as {platform.home}/simulator/ (8530)

18. Create an .alx file for your project.
a. Click the Files tab.
b. Right-click on your project and select New -> Other.
c. In the Choose File Type screen, click Other, then click Empty File.
d. Click Next.
e. In the Name and Location screen, give the file the same name as your project, with the extension .alx.
For example, if bb-secure-musicdb is the project name, name the file bb-secure-musicdb.alx.
f. Click Finish.
g. The empty file opens. Copy the XML code snippet from the point number 10 g from the same link I have 
provided just above for (17), and paste into the file, 
h. Replace myProject with your project name, and including any vendor and copyright information needed for 
your application.
i. Save and close the file.
19. Copy the file mep_client_api.cod from the directory C:\sgmp-client-1_1_01-fcs-b02\lib\BlackBerry to the  
simulator directory of the BlackBerry JDE 
(for example, C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0\simulator).
20. Click the Projects tab, then right-click on your project and select Clean & Build.
21. Right-click on your project and select Run.
The BlackBerry Device Emulator will appear on your screen. Click on the Menu Button on the emulator, 
go to the Downloads, then you will find your application in the list. Click on it, and your application will run.


Now I am going to conclude this by giving special thanks to all the guys who have helped me on various forums, authors of other blogs and books which I have read before to carry out my task, without them I couldn't write this.

I hope it will work for you also, all the best.