Blackberry Development 2: Steps for an app

A step guide for a simple app development by using Eclipse and Blackberry Plug-In. This is the follow up of my previous post Blackberry Development 1: setup environment.

2.1. create a project in Eclipse

To create a new BlackBerry project, click the File menu, and choose New Image from book BlackBerry Project. Name your project HelloWorld, and click Finish.

What is created?

The IDE will create the following:

  • src folder: Where all our source files will reside
  • res folder: Where all resource files (i.e., images) will reside
  • JRE System Library: The BlackBerry runtime library containing the BlackBerry API (by default, it is OS 7)
  • BlackBerry_App_Descriptor.xml file: A file where you can configure your application, including the name of the application and the icon your application will use

 2.2. Create a main application class

Right-click the HelloWorld project icon in the Package Explorer, and from the pop-up menu, select New Image from bookClass. In the dialog, type the following values:

  • Package: com.henry416
  • Name: HelloWorldTest (you can leave off the .java file extension)
  • Superclass: net.rim.device.api.ui.UiApplication
 What is created?

The application class is created and performs the following:

  • Create an instance of the application

  • Create the main screen and push it onto the display stack

  • Start the event dispatch thread

package com.henry416;

import net.rim.device.api.ui.UiApplication;

public class HelloWorldTest extends UiApplication {

    public HelloWorldTest() {
        // TODO Auto-generated constructor stub

     * @param args
    public static void main(String[] args) {
        // TODO Auto-generated method stub



2.3. Create a main screen class

Click New Image from book Class again (or right-click the package in the tree view and select New Image from bookClass, and you won’t have to reenter the package name). Fill in the following values:

  • Package: com.henry416

  • Name: HelloWorldMainScreen

  • Superclass: net.rim.device.api.ui.container.MainScreen (or type MainS, and press Ctrl+spacebar)

 What is created?
package com.henry416;

import net.rim.device.api.ui.container.MainScreen;

public class HelloWorldMainScreen extends MainScreen {


2.4. Add code to the Hello World Classes

Go back to HelloWorldTest, our main class. Fill in the constructor of HelloWorldApp. This will create the main screen and push it onto the display stack:

class HelloWorldTest extends UiApplication {
    HelloWorldTest() {
        HelloWorldMainScreen mainScreen = new HelloWorldMainScreen();

The main method will create an instance of our application and start the event dispatcher, which is the mechanism that does all the drawing to the screen, and listens for all user interaction for our application.

class HelloWorldTest extends UiApplication {
    public static void main(String[] args) {
        HelloWorldTest app = new HelloWorldApp();

The enterEventDispatcher method will never return as long as the application is running. Essentially, the thread that entered the main application becomes the event dispatch thread. We’ll explore this in greater depth later, but for now, just remember that the method won’t return during the application’s normal life cycle.

2.5. Code the Main Screen Classes

Add some GUI components to our main screen class with the following code for

public class HelloWorldMainScreen extends MainScreen {
    public HelloWorldMainScreen() {
        net.rim.device.api.ui.component.LabelField labelField = new
net.rim.device.api.ui.component.LabelField("Hello World");


Note that we subclass MainScreen instead of Screen because MainScreen gives us a couple of things automatically—namely a basic layout manager (to position our UI controls on the screen) and a default menu.  

2.6. Test the app in the simulator

Click the arrow next to the debug icon on the Eclipse toolbar, and select Debug Configurations. Each configuration can have different debug parameters, and as you develop applications, you’ll likely end up with a few different configurations for debugging different OS versions, screen sizes, and so on.

Select the BlackBerry Simulator icon on the left side, and click the New button on the toolbar in the dialog window.

On the Project tab, check the newly created HelloWorld project. Then click the Debug button at the bottom of the dialog. The simulator will launch with your application deployed.

After you click the Debug button, the simulator will start up. When it is finished, you will see your HelloWorldTest on the BlackBerry simulator home screen,

Click the app icon to test…

About henry416
I am a computer technology explorer and an university student based on Toronto. If you have any question, please feel free to discuss and comment here

One Response to Blackberry Development 2: Steps for an app

  1. Hello Henry ,I like to develop a blackberry app but I dont have that much of tutorials or references , I already know how to setup and create a basic app , but want to see more about advance topics like networking and SQLite . thanks for sharing this tutorials.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s