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. 

http://docs.sun.com/app/docs/doc/820-3753/ghjjt?a=view


   
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" 
       description="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 5.0.0.386 (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{/}5.0.0.386 (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 sgmp-client-1_1_01-fcs-b02.zip 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

C:\sgmp-client-1_1_01-fcs-b02\lib\BlackBerry\mep_client_api.jar

e. Click OK.
f. Click on the Files tab, just next to Projects tab and open the project.properties 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,

file.reference.mep_client_api.jar=C:/sgmp-client-1_1_01-fcs-b02/lib/BlackBerry/mep_client_api.jar

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 /5.0.0.386 (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/5.0.0.386 (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.





18 comments:

chirei said...

Hello,
thank you for a helpful post. But I am still having some trouble.
I went through all your steps for the 9500-emulator.
But when I try to run my application from NetBeans, the Blackberry emulator opens (hurray!), but it does not open with my application in it :( I only get the main screen of a blackberry phone.
Any ideas what is wrong?

Google Preneur said...

I have the same problem with chirei hehe... any ideas too?:D

bX-9ugnk9

Purohit D said...

Java development services with dedicated Java developers. Java development outsourcing with proficient Java Developers.

sukumar said...

ya java is most importance in the programming now also mobile application with java program.Mobile Application Development

eugene said...

Do you have any idea why I would receive an error saying: "JVM Error 104 Uncaught: IllegalArgumentException" when trying to run a simple HelloWorld application? I've followed all the instructions needed to load the JDE and configure NetBeans, copied code exactly from the BB Getting Started PDFs - click to run the application in the Emulator using NetBeans and receive this error. The BlackBerry JDE runs applications just fine - Thanks for any help.

HotBlogs said...

Sorry for bit late reply Eugene, Not sure about your problem, but try to change the name of the midlet to "package.classname"; IE in the NetBeans project settings for the MIDlets, try specifying fully qualified name, like com.mypackage.MyMainClass of the main midlet class. I hope it will work for you, but not sure. Best Luck.

Gary said...
This comment has been removed by a blog administrator.
Mobile Application Development said...

Thanks for sharing nice information about Blackberry Emulator. Mobile Application Development useful for iPhone development and Android Mobile Application Development. Awesome post.

Mobile Application Development said...

Thanks for sharing information about blackberry emulator. Ya, you are right java is a best choice for mobile application development because Java is light weight and can produce dynamic instruction with users.

Blackberry Application Development

Mobile Application Development said...

Hello,
Today, everyone knows that this is the booming age for mobile application development market. This has caught an importance of every mobile and technology lover recently and its demand in the market has grown very rapidly.

mobile application development

Jon Pond said...

Where is the XML that you are referring to?

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.

http://docs.sun.com/app/docs/doc/820-3753/ghjjt?a=view

Sir J. Debroy said...

It seems that the link is now redirecting to a generic doc page from Oracle.
Can you post it somewhere else? I was trying to make the procedure, but without the xml am just stalled.
Thanks!

blackberry application development said...

Great work dude, u gave nice post to us. Thanks for spending the time to discuss this, I feel strongly about it and love learning more on this topic.
Customized Blackberry Apps Development

software said...

Nice and very helpful, it's been available Integrating BlackBerry emulator in NetBeans IDE.

Shaimel Singh said...

Hi
Did anyone manage to find that XML?

ken_vip_ said...

http://docs.oracle.com/cd/E19957-01/820-3753/ghjjb/index.html

This is the page, but i have not way to ge any bundle :(

Chris said...

i think mostly java experts shifted on ror application development and become ruby on rails consultants
anyway thanks for share will try this.

João Costa said...

Hello,
my question is what emulator can i use to my blackberry bold 9700?? thanks for help