BlackBerry Java Application Development using Visual Studio

Introduction

BlackBerry JDE or any other platform like NetBeans could be used for BlackBerry java application development. As a .NET developer I prefer using Visual Studio because of the features it provides over BlackBerry JDE and try to explain the same in this article

Background

I have been using BlackBerry JDE for a while now since I started BlackBerry development. After becoming familiarized with the 4.2.1 API that I am using, I decided to use Visual Studio because of its capabilities and find it very handy. I still use BlackBerry JDE for debugging & signing purposes when required.

Details

Here are the cons and pros before you decide if you want to use Visual Studio

Cons

  • Debugging
  • Signing
  • RIM BlackBerry API Intellisense
  • Error Navigation (Cannot navigate to the error line from output window but could navigate to the file)

Pros (over RIM JDE)

  • Better Syntax Highlighting, Code Outlining (CTRL + M, O – collapses everything)
  • Intellisense
  • Code Snippets (code snippet name – if, for & tab + tab)
  • Commenting & Uncommenting (CTRL + K, C)
  • Better Formatting (CTRL + K, D), Better Navigation(for functions & classes using the top dropdowns), Line Numbers – easier to read.
  • Source Gear Vault Integration
  • Better Search, Replace & Bookmarking capabilities(CTRL + K, K to bookmark, CTRL + K, N to move next etc.)
  • Get to use my customized Dark Theme( the best of it)
  • And all other features VS 2005 provides

I use VS 2005 as J# support is removed in VS 2008. Lets consider Hello World project, you could see this line in output window when you build the project in BlackBerry JDE.

  1. C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 C:\BBProjects\helloworld\HelloWorld.java C:\BBProjects\helloworld\img\helloworld_jde.png C:\BBProjects\helloworld\resource\HelloWorldRes.rrc C:\BBProjects\helloworld\resource\HelloWorldRes.rrh C:\BBProjects\helloworld\resource\HelloWorldRes_de.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_en.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_es.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_fr.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_it.rrc

If your project contains too many files, then the above line would be something like this

  1. C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 @com_rim_helloworld_build.files

@com_rim_helloworld_build.files contains all the files included in your project. RIM JDE will automatically create this for you when required

This is important to build in Visual Studio to check if there are any errors in code. Now lets open Visual Studio and create a new J# class library project(C# or J# project does not matter, as the file extension is what that matters)

Create the J# project in a different directory, delete the default class1 file, close VS and move the J# project contents to your existing blackberry project so that everything is in one place. Now open the project in VS and include the necessary files. This will look something like this at this point

Now that you have included the files, you can code in visual studio and would require to build project to check for the errors. Lets create a batch file to build java project from within the Visual Studio. Here is the code for building and showing if succeeded or not.

  1. "C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe" -quiet import="..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=com_rim_helloworld com_rim_helloworld.rapc warnkey=0×52424200;0×52435200;0×52525400 C:\BBProjects\helloworld\HelloWorld.java C:\BBProjects\helloworld\img\helloworld_jde.png C:\BBProjects\helloworld\resource\HelloWorldRes.rrc C:\BBProjects\helloworld\resource\HelloWorldRes.rrh C:\BBProjects\helloworld\resource\HelloWorldRes_de.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_en.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_es.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_fr.rrc C:\BBProjects\helloworld\resource\HelloWorldRes_it.rrc
  2. @echo off
  3. if not exist "com_rim_helloworld.err" goto 20
  4. @ECHO "Build Failed."
  5. goto end
  6. :20
  7. @ECHO "Build Succeeded."
  8. del com_rim_helloworld.cod
  9. :end

Create a batch file using the above code in the project directory and add this into external tools to run within VS. You could do the same using MenuBar: Tools–>External Tools. Add one and setup the batch file, initial directory etc as shown below

You could set a keyboard shorcut like SHIFT + CTRL + F7 and execute it, you will see the results in output window.

Just change something in the code and build again(using shortcut or external tool), you will see the error details. You could then navigate to appropriate file from clicking in the output window

That’s it you are all set up for BlackBerry java application development in visual studio. I use both Visual Studio(for development) and BlackBerry JDE(for debugging & signing) to get the best of both worlds.

Also the BlackBerry build and signing process could be automated using BB Ant Tools if required.

Download

Download the J# Project with all the files here

Hope you find this article useful, happy coding and have fun!

Ponnu

Leave a comment

Your comment

Spam Protection by WP-SpamFree