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:
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.
When you click on the Button, then it displays a message with the name you entered in the EditField.
And when you quit the application then it also shows a message with the text from the field.
If you still have questions, just follow me on Twitter: twitter.com/FabianMH