Click here to Skip to main content
Click here to Skip to main content
Go to top

BlackBerry Java Application Development Using Visual Studio

, 22 Feb 2009
Rate this:
Please Sign up or sign in to vote.
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 the BlackBerry JDE, and I will try to explain the same in this article.

Background

I have been using the 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 the BlackBerry JDE for debugging and 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 the 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, and tab + tab)
  • Commenting and uncommenting (CTRL + K, C)
  • Better formatting (CTRL + K, D), better navigation (for functions and classes using the top dropdowns), line numbers - easier to read.
  • Source gear vault integration
  • Better search, replace, and 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 VS2005 provides

I use VS2005 as J# support is removed in VS2008. Let's consider a Hello World project. You could see this line in the output window when you build the project in the BlackBerry JDE.

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=0x52424200;0x52435200;0x52525400 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:

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=0x52424200;0x52435200;0x52525400 @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, let's 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 the project to check for the errors. Let's create a batch file to build the Java project from within the Visual Studio. Here is the code for building and showing if succeeded or not:

"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=0x52424200;0x52435200;0x52525400 
  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
  
@echo off
if not exist "com_rim_helloworld.err" goto 20
@ECHO "Build Failed."
goto end
:20
@ECHO "Build Succeeded."
del com_rim_helloworld.cod
: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 the menu bar: Tools-->External Tools. Add one and setup the batch file, initial directory etc., as shown below:

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

Just change something in the code and build again (using the shortcut or an external tool), and you will see the error details. You could then navigate to the 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 and signing) to get the best of both worlds. I have included the J# project with all the files in it.

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

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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ponnurangam D
Software Developer GMS Ltd.
United Kingdom United Kingdom
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 PinmvpKanasz Robert23-Sep-12 3:11 
GeneralSource Download link is not working PinmemberMuhammad Fuad7-Sep-10 0:02 
QuestionGetting compile error with attached source code PinmemberAmit Joneja17-Apr-09 6:07 
AnswerRe: Getting compile error with attached source code PinmemberPonnurangam D17-Apr-09 7:07 
GeneralRe: Getting compile error with attached source code PinmemberAmit Joneja17-Apr-09 9:36 
GeneralRe: Getting compile error with attached source code PinmemberPonnurangam D17-Apr-09 10:09 
GeneralRe: Getting compile error with attached source code PinmemberAmit Joneja17-Apr-09 11:02 
AnswerRe: Getting compile error with attached source code PinmemberPonnurangam D20-Apr-09 15:51 
GeneralRe: Getting compile error with attached source code PinmemberAmit Joneja21-Apr-09 5:03 
AnswerRe: Getting compile error with attached source code PinmemberPonnurangam D21-Apr-09 5:32 
GeneralRe: Getting compile error with attached source code PinmemberAmit Joneja21-Apr-09 7:51 
GeneralEclipse PinmemberPaul Selormey22-Feb-09 17:13 
GeneralRe: Eclipse PinmemberPonnurangam D22-Feb-09 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 22 Feb 2009
Article Copyright 2009 by Ponnurangam D
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid