BlackBerry Development Tools – Eclipse Plugin (in beta)

Posted October 22nd, 2008 by Nazmul

We believe in the power of ONE, at ScreamingToaster. We believe in innovation - ONE experience can change a person's life. We believe in partnerships - ONE endeavor can establish lasting trust & mutual success. We believe in education - ONE training course can empower a developer for life. We believe in giving back - ONE open-source project can inspire future entrepreneur. ONE person can become the leader that starts a revolution. ONE company can change the world and make it a better place - join us.

Introduction

There are different tools that you can use for BlackBerry development – Eclipse Plugin and JDE. In this tutorial I will show you how to use the Eclipse Plugin as your IDE for BlackBerry development. Directions are provided on how to install and configure the Eclipse Plugin, then get started with a Hello World project, then deploy the project to the simulator and run it.

Books, devices, and accessories

If you’d like to buy BlackBerry devices, accessories, or user guides, from Amazon.com click here.

Using Eclipse Plugin (Beta)

You can download the Eclipse Plugin from from BlackBerry’s website. Here’s a video how to install the Eclipse plugin. The Eclipse environment is still in beta and has lots of quirks and limitations. For example, if you’re planning on including images (PNG files) in your BlackBerry projects (COD files) then the Eclipse plugin will not work for you. However, it’s quite fast, and modern, compared to the JDE. The following are some quick steps to get started with using the Eclipse Plugin.

Installation

The installer installs Eclipse 3.x if you don’t have Eclipse, or point it to a directory where it exists, and it will just install the BlackBerry plugin for that Eclipse instance. I let the installer install it’s own Eclipse environment, and the plugin. Here are some screenshots of the installation process:

  1. Install Eclipse and the plugin to c:\blackberry\ide\eclipse
  2. Complete the installation:
  3. On to creating your first project:

Creating a project

Launch Eclipse by running eclipse.exe in c:\blackberry\ide\eclipse.

Step 1 – Create the workspace

Step 2 – On first run, after you give it the workspace, from Blackberry menu, select Configure BlackBerry Workspace, then just click Yes.

Step 2.1 – Click OK.

Step 3 – Under the File menu, select New -> Project. Then select Blackberry Project.

  

Step 3.1 – Give it a name, eg: “FirstProject”, then click on Finish.

Step 4 – Create a new Java class

Step 4.1 – Call the class “HelloWorld’, and click Finish.

Copy this code into the source file:

/**
 * HelloWorld.java
 * Copyright (C) 2001-2004 Research In Motion Limited. All rights reserved.
 */

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;

public class HelloWorld extends UiApplication {
    public static void main(String[] args) {
        HelloWorld theApp = new HelloWorld();
        theApp.enterEventDispatcher();
    }
    public HelloWorld() {
        pushScreen(new HelloWorldScreen());
    }
}

final class HelloWorldScreen extends MainScreen {
    public HelloWorldScreen() {
        super();
        LabelField title = new LabelField("HelloWorld Sample", LabelField.ELLIPSIS
            | LabelField.USE_ALL_WIDTH);
        setTitle(title);
        add(new RichTextField("Hello World!"));
    }

    public boolean onClose() {
        Dialog.alert("Goodbye!");
        System.exit(0);
        return true;
    }
}

Step 5 – Set project properties, go to Project -> Properties -> BlackBerry Project Properties, and set all the data (you can set the app icon here):

Step 5.1 – Go to the Resources tab, and you will be able to add an app icon to your project. You can read more about BlackBerry icon sizes and formats here. Click on OK after you’ve made an icon selection (if you want your app to have an icon on the BlackBerry home screen).

Step 6 – The javadoc location is automatically set in Window -> Preferences -> Blackberry JDE -> Installed Components. The default location is – C:\blackberry\ide\eclipse\plugins\net.rim.eide.componentpack4.3.0_4.3.0.8\components\docs\api. Changing anything here, recreates the workspace files.

Step 7 – to run the HelloWorld project, just select Run -> Run, then select the BlackBerry Simulator, then click OK.

Step 7.1 – This launches the default simulator. Click on the Menu button, and you will see the newly added HelloWorld app in there.

Limitations and problems

Images

As of this writing, the Eclipse Plugin is still in Beta, and has some problems. If you want image files (PNG, JPEG, etc) to be available to your BlackBerry app (and end up in the COD file), then you will encounter problems with the plugin, which does not recognize any images that you add to your project.

Adding files to your project manually

If you add external sources or files that you want included in your BlackBerry project, you have to right click on the HelloWorld project, and invoke the “Add File to BlackBerry Project” menu, which will make these files available to rapc.exe when it’s run to compile your code and generate your COD file.

BBDevMgr.exe out of control

Occasionally as you’re running your code in the simulator, you will find your CPU pegged to 100%. This happens when “BBDevMgr.exe” goes nuts and takes over your CPU. I’ve experienced this on more than one machine running Vista x64. I just kill it using my taskmanager or taskkill, without needing to restart the simulator. This problem happens whether you’re using the JDE or the Eclipse plugin. The following chart shows you how often I’ve experienced this problem in the past few weeks.

Restarting the simulator every time you make a change

Every time you make a change to your code, and you want to recompile and redeploy to the simulator, you will have to restart the simulator, before propagating your COD file to it. This takes a lot of time and is really annoying to have to do very frequently. The Android simulator is much better than Fledge in this respect, since you can propagate your changes without having to restart the simulator (which takes time). I’m going to publish another tutorial just on the simulator (called Fledge).

Comments and feedback

To share your thoughts on this tutorial click here.

We do not just build mobile “apps”, we build mobile experiences

Let us build you mobile experiences for Android, BlackBerry, and iPhone. We can also build you cloud-connected experiences that span Mobile (Android, BlackBerry, iPhone), Web (Safari, Firefox, Internet Explorer) and Desktop (PC, Mac, Linux) for a truly connected real-time experience. See our work in action: download RainOrShine for BlackBerry and CityRyde for Android.

  • We provide full service, full lifecycle consulting services (planning, graphic design, architecture, marketing, support, and implementation).
  • We provide Architecture guidance before implementation; marketing strategy after implementation. Click here to learn more.

Zen Application Framework

All our applications are built using our Zen Application Framework, which helps you avoid the common pitfalls around mobile development. Zen drastically reduces development time & cost for mobile, web, and desktop experiences. Click here to learn more.

Our training services make You self-sufficient & sustainable

Want to learn from the best? We offer Android and BlackBerry developer training programs. Whether you are just starting out, or want advanced training, we have courses for different skill levels & technology requirements. Contact us to learn more, and sign up.

Our values: Open-source. Democratization of knowledge. To lead, never follow

We are leaders in mobile technology. We have done and seen it all. We do not follow trends set by others & we do not make the mistakes made by others. We set the trends for mobile because we are mobile visionaries.


Comments are closed.