By Derek Santos – Consultant
The Mobile Market is extremely competitive these days, and it’s important for customers to deploy their applications across multiple mobile platforms. The BlackBerry platform, like Android, is Java based. This lends itself nicely to existing Java and/or Android developers. In this article, we’ll take a look at creating a HelloWorld application using the BlackBerry Mobile Platform.
Downloading and installing the necessary tools
First, you will need to download the BlackBerry Eclipse Plug-in here.
It is important to note that versions of the BlackBerry platform 4.x and earlier are considered legacy and use what’s called the “BlackBerry JDE(Java Development Environment)”. Versions 5.0 and later now use the BlackBerry Eclipse Plug-in. This article assumes you have Eclipse 3.5 installed.
Once you’ve downloaded the installer, simply run it and point it to your existing eclipse installation.
Creating your first BlackBerry project
To create your project, go to New -> Project.
Then select BlackBerry Project.

Click “Next”. Give your project a name then click “Finish”.
Configuring your project
You now have a BlackBerry project setup. You should notice that an application descriptor file was created for you. This descriptor file contains the Meta information about your project. It can be found under the root of your project.

Open this file and enter in information about your project.

Creating your main application class
Now that your project is configured, you’ll want to create a new Java class and have it extend UIApplication. The UIApplication class is your main entry point into the application. This class will also have your static main() function.

Once you’ve created your class, add the code to your static main() method as shown below. The enterEventDispatcher() method indicates that your main application thread will execute any drawing and event-handling code.
HelloWorld application = new HelloWorld();
application.enterEventDispatcher();
}
At this point, you will have an empty BlackBerry Application.
Creating your applications main screen
BlackBerry applications draw screens on a stack. To initialize this stack, we need to create a class that extends the “MainScreen” class. Create a new Java class and configure it as seen below.

After creating the class, create a default constructor and add the following code to it.
super();
long options = LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH;
LabelField title = new LabelField("HelloWorld Sample", options);
setTitle(title);
RichTextField richTextField = new RichTextField("Hello World!");
add(richTextField);
}
Now that you’ve created your main screen, you are ready to add it to your application.
Adding your main screen to the application
To have your application display your main screen, you need to “push” the screen onto the applications stack. To do this, add this line of code to the HelloWorld applications constructor. Also make sure you are calling super().
super();
pushScreen(new SampleMainScreen());
}
Running your application
To run your BlackBerry application, simply click the Run dropdown, go to Run As -> BlackBerry Simulator.

The first run will take some time as the Simulator initializes. Once the Simulator is loaded up, you need to navigate to the application. You can do this by click the BlackBerry menu button then going to Downloads -> My First Application.

Once you click on “My First Application”, your should see “HelloWorld” printed on the screen.
Conclusion
This concludes creating a simple application using the BlackBerry Mobile Platform. For further reading, please see the BlackBerry Developer Zone.
Thanks for reading!


