- return

Developing for BlackBerry using Mobile Processing

The steps below will allow you to easily develop for BlackBerry using Processing, when you make changes to your sketch, export the midlet then clean and rebuild in the BlackBerry JDE - any changes will be visible in the BlackBerry emulator. As ever, if you find any errors or omissions, contact me and I'll make the changes.

Step 1 - Mobile Processing uses Suns Wireless Toolkit for testing so you first need to install the Java SDK and Wireless toolkit.

Step 2 - Once installed run Mobile Processing and goto File > Preferences and select the 'Mobile' tab, set the 'Wireless Toolkit Location' (most likely: 'C:\WTK25', more installation help available on the Mobile Processing site)



Step 3 - Create your sketch, example code from the Mobile Processing site:

PLabel label;
PScrollBar scrollbar;

int value;

void setup() {
label = new PLabel("Value: " + value);
label.align = CENTER;
label.calculateBounds(4, 4, width - 8, height);
label.setBounds(4, 4, width - 8, label.height);
label.initialize();

int y = label.y + label.height + 4;
scrollbar = new PScrollBar();
scrollbar.setBounds((width - 4) / 2, y, 4, height - y - 4);
scrollbar.setRange(0, 8, 1);
scrollbar.initialize();
}

void draw() {
background(255);
label.draw();
scrollbar.draw();
}

void keyPressed() {
switch (keyCode) {
case UP:
value = max(0, value - 1);
break;
case DOWN:
value = min(8, value + 1);
break;
}
label.text = "Value: " + value;
scrollbar.setValue(value);
}

Save your sketch as TestSketch and test it by clicking the play icon (or using ctrl-r), you should see something similar to:


Step 4 - You now need to export your midlet, goto File > Export MIDlet (ctrl-shift-e), this would normally be where you would finish up and test on your mobile but for BlackBerry we first need to convert the MIDlet to a COD. Once Mobile Processing has finished building your jad and jar files it should open the directory containing you files (eg. C:\Documents and Settings\jonathan.fisher\My Documents\MobileProcessing\TestSketch\midlet)

Step 5 - Open the BlackBerry JDE, create a new project in the Mobile Processing sketch folder (eg. C:\Documents and Settings\jonathan.fisher\My Documents\MobileProcessing\TestSketch), to keep things tidy name it the same as your sketch in Mobile Processing.

Step 6 - Right-click on your project in the JDE and select 'Add File to Project', navigate to the midlet directory and set the dialog to display all files, add the .jad and .jar to your project.



Step 7 - Again, right-click on the project node in the JDE and select 'Properties', give your application a title in the first tab (eg. Test Sketch), give it a version number, vendor name and a desciption if desired.



Step 8 - In the 'Application' tab select 'MIDlet' as the project type and enter the name of your sketch and hit 'ok':



Step 9 - You can now build your app and check it works in the BlackBerry emulator:



Step 10 - Before we're done we want to add a nice icon for our application, create a suitable image at around 32 by 32 pixels in the .png format, put it in the midlet/ directory and add it to your project in the JDE (select files of type '.png' in the add dialog), right-click the icon in the JDE file list and select 'Use as Application Icon', rebuild your application and test it in the emulator:



Note: Depending on what your sketch does you may require to have code-signing keys for your final .cod before it'll run on a real device, more info here, build your project in the Blackberry JDE, select your project node in the Files pane then from the menu select > Project > Generate ALX File - this creates a small xml file similar to a .jad that allows the BlackBerry Desktop Installer to load your .cod onto a physical device.