How to write your first BlackBerry application – Lesson 1: UI fields

149 Comments

software development

This article is the first in a series of articles about BlackBerry development. With App World, third party software vendors and the web, there are a ton of opportunities for an independent developer to make money.

BlackBerry Development in Java – Lection 1: Basic fields in the User Interface

Let’s get right into it. Download the JDE (Java Development Environment) from the BlackBerry website. I personally used the JDE 4.3 for this project but you can also download a newer JDE. For advanced functions like using the BlackBerry Storm accelerometer or touch screen, you have to install JDE 4.7.

For advanced features and other APIs you may want to use, you need code-signing keys from RIM. You can purchase signing keys here. The keys cost $20 which is a bargain considering you can use the keys forever, and they’re going to help you make a great BlackBerry application. Make sure to read more about the keys because they’re an important part of BlackBerry development.

For this introductory application, you don’t need signature keys and the compiled *.cod file can be run on the device (and not only on the simulator).
 
How to setup the JDE:

After installation of the JDE, launch it and then click on:

    1. File -> New
    2. Workspaces – Tab
    3. Name it Lections
    4. Click OK

Then on the left side in the JDE, you see the Tab Files. Click on:

    1. Lections.jdw (Right click)
    2. Select Create new Project
    3. Name it Lection_1
    4. Copy the two files GreetingScreen.java and HelloWorld.java into the same folder where the Lesson_1.jdp file is (the main project folder)
    5. Click on Add File to Project and select both *.java files
    6. Now both *.java files appear under Lection_1
    7. Click on those in the list to open them up in the JDE
    8. Now you’re ready to go, you have successfully imported the files and can now work with them.
    9. Press F7 to compile the application or press F5 to run the application on the simulator.
    10. The application is compiled to a *.cod file.
    11. The *.alx file (for Desktop Manager installation) needs to be created manually by the user:
    1. Right click on Lection_1 and then on Generate ALX file.
    2. Now the *.alx file is created and the application can be installed via Desktop Manager.
    3. The *.alx file and the *.cod file have to be in the same folder for installation.

That’s how the ‘Files’ should look like on the left side of the screen:

BlackBerry Development 1
 
The *.java Files:
 
We have two *.java files for our Project. The one is the HelloWorld.java file and the other one is the GreetingScreen.java file.
 
The HelloWorld.java file does the following:

You want your application to show the user a graphical user interface; that’s why you need your HelloWorld class to extend the UiApplication class. The UiApplication class can be found here in the APIs: net.rim.device.api.ui.UiApplication.

A BlackBerry application always starts with the main() method. In the main() method the first thing that happens is that an instance is created by calling the constructor. The constructor uses the UiApplication class to use the pushScreen() method to show the GreetingScreen.
 
The GreetingScreen.java file is a bit more complicated but if you follow the comments then you will soon find out what it does.
 
So what does the application actually do?

This is the main screen of the application; it contains a ButtonField, a Title, a LabelField, a SeparatorField and an EditField.

BlackBerry development lesson 1

When you click on the Button, then it displays a message with the name you entered in the EditField.

BlackBerry development

And when you quit the application then it also shows a message with the text from the field.

BlackBerry development
 
If you still have questions, just follow me on Twitter: twitter.com/FabianMH

ED NOTE: Check out Fabian’s software page. He’s got some useful apps to improve your BlackBerry experience, as well as some cool BlackBerry Storm software.
 

  • Mornej Jooste

    Hi I get an error

    Error: java compiler failed: javac -source 1.3 -target 1.3 -g -O -d C:UsersADMINI~1.SERAppDataLocalTemp1rapc_1adcf666.dir …

    How do I correct this?

  • Stephan

    LOL.. I tink u shud consider some anger management!

  • http://www.facebook.com/people/Adebisi-Oje/635888641 Adebisi Oje

    Hey!
    I try running the helloworld program and I get a GUI pop up that says “attempting to connect to VM”… then I get a null pointer exception
    ??
    lost.

  • Skilmaster98

    huh i did exactly what they said but i don’t get that folder named “lection1″ its just Lections>Lection_1 and not Lections>Lection1>lection_1

  • Mike

    Man you’re awesome! I wonder what will happen if you experience a real problem some day :-D

  • daVC

    wat ? !!! were u forced to read the post at gun point  ????

  • svdv22

    You guys don’t understand… there is no. fuckin. cod. file. ;-)

  • svdv22

    You guys don’t understand… there is no. fuckin. cod. file. ;-)

  • neha

    hey thanks for the few lessons they are just awesome & so helpful!! but i want some more help like how to work with images, bluetooth etc as i am new in developing BB apps.

  • Fashfemi

    lol

  • Esteban Gonzalezm

    Great tutorial!
    I had a problem because the COD file was in bin directory, i create the project again and works perfect.

    Thanks Fabian

  • guest monkey

    wow this guy below me has issues

  • Ians Mate

    Looks like Ian 1324 has an anger management issue! Dick

  • Svdv22

    Another knob with anger management issues

  • Knoxy

    lol, still laughing after a few minutes – take a deep breath Ian lol

  • tooqy

    Wow… It’s cool & clear example..
    Thanks for it..
    -2Q-

  • tooqy

    Wow… It’s cool & clear example..
    Thanks for it..
    -2Q-

  • Girishk Sharma

    It’s Helpful thanks

  • Shatner

    no. fucking. cod. FILE!!!!! 

    anywhere. i. tried. pressing. f7. so. many. times….it hurts…

  • Test

    Maybe your keyboard is broken? Pressed the F7 key to many times??

  • Test

    Maybe your keyboard is broken? Pressed the F7 key to many times??

  • Anonymous

    That’s horrible, is like developing an app using a typewriter.
    When will be possible to draw a GUI by drag and dropping controls to a form, and then just assign instructions to controls events??
    Jesus!!! we’re already living in 2011..!!!!

  • Zapra

    I using Blackberry Java Plug-in, but they show me 25 errors between “type” and “variables” 

  • friendly advice

    your not paying for this info, just calm down if you want better info i recommend you pay for it and stop annoying the person who took all the time to give you FREE info, fs no respect from some people these days :/

  • Anon

    Yeah, it’s called programming.

  • Anonymous

    Oh, I see..
    So, Visual Basic or Delphi developers are not programmers, because they don’t need to write code to draw forms, buttons and text boxes?

    And the real idea of programming is a Hello World application in 20 “easy” steps?

    I disagree!!

  • H0LYL1F3

    Can anyone please help me? i do everything and when i hit F7 there is no problem, but when i look for the COD file i can’t find it :(   I can’t run it on my simulator because my simulator is broken (i have to re download it but i cant afford the bandwidth).  but that wouldn’t be the problem would it?  if anyone can help i would appreciate it. thanks 

  • frasco inc

    dude
    u shouldnt even be expain wat that twat did wrong
    it pp think this that dont have respect that aways get fucked in life

  • Adi3tz Ophelia

    i just still begin to learn be blackberry programmer, cool Mr. Fabian :)

  • Adi3tz Ophelia

    i just still begin to learn be blackberry programmer, cool Mr. Fabian :)

  • suBerman

    Thank you very much! And I hope Ian 1324 is feeling better now..

  • Mr.fuck

    1324, i read ur fucking comment got all fucked up….

  • Mr.fuck

    1324, i read ur fucking comment got all fucked up….

  • Mr.fuck

    katta :P

  • Mr.fuck

    katta :P

  • Cliff

    Hi
    Excellent !
    I am now on my way with this compiler.
    You helped me a great deal cheers
    keep up the good work.
    cliff.

  • http://namastu.com/ SEO

    Hey Man…….There is no code file . 

  • http://namastu.com/ SEO

    Hey Man…….There is no code file . 

  • http://www.mobileappsplanet.com/ Mathew Nss02

    If you are looking for a professional BlackBerry developer visit http://www.mobileappsplanet.com 

  • Fadas

    i Dont really Like Dis sIrrr

  • Zoidy

     his was a paths problem the IDE cant find the Java build.exe in the Java app folder. you need to add paths to windows environment and it works fine. If you remain calm you can approach the problem with a problem solving approach

  • ConfusedGuy

    Help Needed
    its giving me this error :
    I/O Error: Cannot run program “javac”: CreateProcess error=2, The system cannot find the file specifiedError while building project

    what do i do

  • Super_XP

    Nice work.

  • http://www.parkerpen.web.id/ Bolpen Parker

    this is why blackberry will dead, its must pay. try develop for android its more exciting all its free

  • http://www.parkerpen.web.id/ Bolpen Parker

    this is why blackberry will dead, its must pay. try develop for android its more exciting all its free

  • Fuck

    Coulda been changed to a HADDOCK file….. Ha ha ha ha ha

  • Matrixshopping

    i cant even get the first download

  • http://www.facebook.com/matrixcalls Larry Morgan

    man the file is missing that i clicked

  • BahRain-bb

    How to create a program for BlackBerry
    When you open the program goes to my site