Click here to Skip to main content
15,884,099 members
Articles / Mobile Apps / Blackberry

BlackBerry Java Application Development Using Visual Studio

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
22 Feb 2009CPOL3 min read 71.8K   534   36   13
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.

Image 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=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):

Image 2

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:

Image 3

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:

Image 4

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

Image 5

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:

Image 6

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)


Written By
Software Developer GMS Ltd.
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

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

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

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