Tuesday, December 8, 2009

Blackberry - Java Application Development - Get Started

1. Download Development Tools
We can use RIM(Risearch In Motion) Blackberry JDE, But for java developers it is easy to work with Eclipse environment

So we can download these java-eclipse development tool for blackberry JDE from HERE

Downloaded this plug-in from above link..

Top Tools

Prerequisites: Installing the BlackBerry JDE Plug-in for
Eclipse
Ensure that your computer meets the following requirements before you install and run the BlackBerry® JDE Plug-
in for Eclipse™:
• Computer monitor with resolution 1024 x 768 or higher
• Intel® Pentium® 4 Processor (minimum 3 GHz)
• 1.5 GB Hard drive
• 1 GB RAM
• Microsoft® Windows Vista™, or Windows® XP
• Java® SE Development Kit (JDK) version 5 or version 6 (download from the Sun® Microsystems web site).
Version 6 is required if you are using BlackBerry MDS-CS for debugging.
• You can use the BlackBerry JDE Plug-in for Eclipse with an existing installation of Eclipse IDE for Java
Developers version 3.4.0.

Setting up the BlackBerry JDE Plug-in for Eclipse

To create a BlackBerry Application for a specific version of BlackBerry Device Software, you must use a version of
the BlackBerry® Java® Development Environment or component pack plug-in that matches the version of
BlackBerry Device Software that you want to run the application on.
1. In Eclipse™, on the Window menu, click Preferences.
2. Expand the BlackBerry JDE item.
3. Select Installed Components.
4. In the Components section, select an installed component from the drop-down list.
5. Click OK until the Preferences window disappears.
Change the heap memory for Eclipse
1. Create a shortcut to the Eclipse™ executable.
2. Right-click the executable and add the following parameters to the properties: -vmargs -Xmx256M

Enable application preprocessing
You can enable preprocessing for your applications by updating the Eclipse™ configuration file.
> In C:\Program Files\Eclipse\configuration\config.ini, add the following line:
osgi.framework.extensions=net.rim.eide.preprocessing.hook
If you enable preprocessing after you have had a build, you must clean the project from the Project menu before
you build the project again.

Create an application for a specific version of the BlackBerry Device Software
1. In Eclipse™, on the Window menu, click Preferences.
2. Expand the BlackBerry JDE item.
3. Select Installed Components.
4. In the Components field, select a BlackBerry JDE component package plug-in.
5. Click OK.

Enable functionality similar to the BlackBerry Java
Development Environment
1. Open the Eclipse™ workspace.
2. On the Window menu, select Preferences.
3. Expand the General item.
4. Select the Workspace item.
5. Clear the Build automatically option.
6. Clear the Refresh automatically option.
7. Select the Save automatically before build option.

Removing the BlackBerry JDE Plug-in for Eclipse
If you used the installer for the BlackBerry® JDE Plug-In for Eclipse™, perform the following steps to remove the
plug-in:
1. Close any instances of Eclipse.
2. In the file system, browse to the Eclipse installation directory.
3. Browse to the Eclipse\plugins folder.
4. Remove the following files and folders:
net.rim.eide.bootstrapper_ *.jar
net.rim.eide.componentpack_*
net.rim.eide.doc_ *.jar
net.rim.eide.preprocessing.hook_*.jar
net.rim.eide_ *.jar
5. Browse to the Eclipse\features folder.
6. Remove the following folders:
net.rim.EclipseJDE_*
net.rim.eide.feature.componentpack*
7. Browse to the configuration folder and remove the following line from the config.ini file:
osgi.framework.extensions=net.rim.eide.preprocessing.hook

Creating your own HelloWorld

Hope that you all are familiar with Eclipse

Click File -> New -> Project

In the window, drill down the blackberry and select blackberry project

give project name and click finish

In src folder, create a class HelloWorld under the package com.sample



orkspace… and then give your program a name like MyHelloWorld. In the second box add MyHelloWorld to the end of the creation path leaving off the last backslash. Click Ok and then Yes to the directory creation question. You now have a new workspace in which to put your project.


/**
* The sentinal sample!
*
* Copyright ¨ 1998-2007 Research In Motion Ltd.
*/

/**
* The sentinal sample!
*
* Copyright ¨ 1998-2007 Research In Motion Ltd.
*/


package com.sample;
import com.resource.*;
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.i18n.*;
import net.rim.device.api.system.*;

import net.rim.device.api.collection.util.*;

public class HelloWorld extends UiApplication
{
//statics ------------------------------------------------------------------
public static void main(String[] args)
{
HelloWorld theApp = new HelloWorld();
//To make the application enter the event thread and start processing messages, we invoke the enterEventDispatcher method
theApp.enterEventDispatcher();
}

/**
* <p>the default constructor. Creates all the RIM UI components and pushes the application's root screen onto the UI stack
*/
public HelloWorld()
{
//Push the main screen instance onto the UI stack for rendering.
pushScreen(new HelloWorldScreen());
}

}

/*package*/ final class HelloWorldScreen extends MainScreen implements HelloWorldResResource
{
//members ------------------------------------------------------------------

/**
* <p>It is RIM recommended practice that you internationalize your code from the
* beginning. In order to do so, you'll need to create an RRH file, and various
* RRC files, one for each language or dialect you intend to support.
* Review the associated RRH and RRC files included with this project. Notice
* that the HelloWorld class implements a resouce interface. That interface
* is automatically generated from the RRH file.
*/
private static ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);

/**
* Add the title and a simple richtext field
*/
public HelloWorldScreen()
{
super(DEFAULT_MENU | DEFAULT_CLOSE);

//Add a field to the title region of the screen. We use a simple LabelField here. The ELLIPSIS option truncates
// the label text with "..." if the text was too long for the space available.
setTitle(new LabelField(_resources.getString(HELLOWORLD_TITLE), LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH));

//Add a read only text field (RichTextField) to the field portion of the screen. The RTF is focusable by default.
add(new RichTextField(_resources.getString(HELLOWORLD_CONTENTSTRING)));
}

public boolean onClose()
{
Dialog.alert(_resources.getString(HELLOWORLD_EXITSTRING));
System.exit(0);
return true;
}

public boolean keyChar(char key, int status, int time) {
//intercept the ESC key - exit the app on its receipt
boolean retval = false;

switch (key) {
case Characters.ESCAPE:
onClose();
retval = true;
break;
}

return retval;
}
}

//It will be good if anyone suggest me to format the source above, if any online resource?

In the above HelloWorld program we are using language Resource, To do this,

File->New->Project, and select "Blackberry Resource File"

give file name to HelloWorldRes.rrh and select the folder sample in our project src path

Finish.

open the file and add these key and values

HELLOWORLD_TITLE as key and value as "HelloWorld !!"
do similar for
HELLOWORLD_CONTENTSTRING
HELLOWORLD_EXITSTRING


Build and Run the Program..

Run As Blackberry Simulator

After Launching Simulator, click the menu key, it will list all Applications, Select our application and open it..


How to set icon for the Application:

will be back at evening :)

13 comments:

  1. Hi
    Great blog i like it
    The latest Blackberry Storm is a high-end touch smart phone with a 3.2 mega pixel camera and many more promising features to offer.

    ReplyDelete
  2. Hello,
    Nice blog i like it
    Take the case of mobile banking for instance. How easily one can access one's account or check balances or transfer funds between accounts, along with the versatility of the banking services offered would decide the effectiveness of mobile application development.

    ReplyDelete
  3. Hey David, Awesome post!!!!! Thanks for sharing knowledge. This will help the beginners to create a blackberry application.

    Blackberry Application Development

    ReplyDelete
  4. hey nice post!!! I seriously enjoy your work on this blog and the quality posts you wrote..

    ReplyDelete
  5. Tremendous blogging. An iPad application development company can also build you an application that will help your kid enjoy yet study.

    ipad apps development

    ReplyDelete
  6. INFORLINX is a leading provider of consulting services and technologies that enable clients to achieve real business value using state-of-the-art information technology.

    ReplyDelete
  7. This is good info! Where else can if find out more?? Who runs this joint too? Keep up the good work
    Customized Blackberry Apps Development

    ReplyDelete
  8. This is an excellent blog post on Java application development. Earlier, I tried to use the Java development environment for BlackBerry. I had problems downloading it…but I clicked on your download link and it was very easy. Also, the tutorial that I followed earlier wasn't detailed and that's why, I couldn't know all the requirements; I had 512 MB RAM and I still tried to install the JDE.

    ReplyDelete
  9. Very informative post about blackberry - java app development. Every reader will getting quality info from this blog. Thank you for share this kind of useful post.

    ReplyDelete
  10. The BlackBerry Java Development Environment (JDE), which combines an SDK, an IDE, and a set of simulators, has tortured developers for years. This Swing-based application gets the job done, but it employs a user interface that screams 1994, perplexing debugging, and inconsistent keyboard shortcuts.

    ReplyDelete
  11. Very Informative post. Nice read! Thanks for sharing the information. Kepp posting.
    Visit - Mobisoft Infotech

    ReplyDelete
  12. Great. It is good to constantly coming up with creative ideas. Provides much needed knowledge. goal oriented blog posts and always tried to find creative ways to meet goals.
    Thanks!!
    Healthcare Mobile App Development | Top 10 Healthcare App Development Companies

    ReplyDelete