Going Mobile with RIM’s BlackBerry 8100

Recently I’ve been looking at mobile application development with J2ME (Java 2 Micro Edition). Programming on mobile devices really is a tricky problem. Screen sizes are all different, memory is very constrained, processors are not exactly “robust”, and even keypads are different from platform to platform. So what’s a techie-programmer to do? Grab your phone and crack open some tools I say! Arrggh! (Sorry there’s a Mythbusters Pirate show on…)

The only thing to do is grab your own phone and try stuff out. Since I work for a big company I’ve got a typical corporate phone – a RIM 8100 Blackberry Pearl. You’ve got a couple of options for programming on the Pearl – there’s a .NET set of tools and a Java set. Surprise surprise, the Java tools work for me. RIM’s J2ME stack is pretty complete and included JSR-80 and JSR-120, two key sets of APIs for SMS texting and for Bluetooth support. There’s also a bunch of very nice crypto APIs for later on if I get stuff working right.

RIM has a nice developer site with easy links to download the development tools that you need. For Java there is the “JDE” (Java Development Environment). This is a comprehensive IDE that includes about 50 sample programs. Although it is a little sparse compared to full IDEs, this is the best option for getting some initial programs working.

In the Beta area there is new Eclipse based plugin that you can grab. I grabbed this for later. This is a complete replacement for the JDE environment.

Also on the RIM site are various simulator tools. You can download these and then use them as a good way to pre-test your app before loading it on your phone (I need my phone so pre-testing is good). I grabbed several

of these simulators. Once installed they load up on your desktop and present you a complete “virtual b-berry”. You can load your programs up right off the menu.The simulator runs just like the real thing and worked fine with my laptop’s pointing-stick and buttons. The simulator even has a screen saver and power saving modes. Pretty cool!

RIM’s J2ME supports both the older CLDC standard and the somewhat newer MIDlet 2.0 standard for application design. The samples use both, although most of the simple ones are CLDC. Basically these are just different application frameworks. Eventually I’d like to use MIDLet – but for now I’d juts like to get something to work. The next step is to startup JDE 4.6 (the latest at writing).There’s a bunch of links down at the bottom if you still need to grab software.

When you open up JDE you will see a whole bunch of samples. The IDE looks a bit er well ancient, but it’s got enough features and good integration with the simulator tools. There’s syntax highlighting,  code assist, integrated debugger, etc. To build the application just pick off the “build” or “build all” choice. You might get an error in the console about rapc.exe not being able to find javac. JDE needs to have a java bin on the PATH. I found modifying the .bat file (located at C:Program FilesResearch In MotionBlackBerry JDE 4.6.0binide.bat ) that starts up the IDE the best way to do this. You might get some errors or warnings from some of the examples complaining about “signing keys” – more on that later.

Above is both environments – Eclipse is on the right (or the bottom is it wraps around). Pretty similar, but I prefer the 3.2 based Eclipse plugin. The Eclipse plugin recognized that I already had JDE installed and correctly imported my configuration into a “Blackberry Workspace”. you create projects with the wizards per the normal Eclipse deal.

The best reason to install JDE is that its the only way I can figure out to get the full JavaDocs for the APIs local on your machine.

I was able to import my JDE projects easily and build them straight off. Use the File…Import option and then you’ll see options to import projects from your JDE config. I wanted to keep all my JDE projects safe from harm. When I started up Eclipse I had it create a new workspace under where I had installed it (I have about 10 different Eclipse configs on my machine so I didn’t want to screw those up). I also told it to use hte JDE structure. When I tried the “make it look like an Ecipse project” I would get null pointer errors. It is beta code so keeping that unchecked gets me going just fine.

When the build is complete you will have several new files. The program to load up in the simulator is the .cod file. Once its loaded it should show up in either the “downloads” folder or right on the main screen. I tried the “HelloWorld” program and it worked straight off. Cool, but how do I get this on my phone? There are several ways to get the app onto your phone, but the easiest is to use the “JavaLoader” program included with JDE along with a USB cable. Plugin your phone to the USB port and use the follow command to send you app over:

C:Program FilesResearch In MotionBlackBerry JDE 4.6.0binJavaLoader.exe -usb load C:BB-EclipseworkspacesamplescomrimsamplesdevicehelloworlddemoHelloWorldDemo.cod

To use JavaLoader your PC must actually recognize your device when its attached. You can get a driver from either the windows update site or my installing your RIM desktop manager. I just installed the driver, connected my device and ran the JavaLoader.

You can take a screen shot of the running application with JavaLoader.exe using this command:

JavaLoader -usb screenshot shot.bmp

Here’s my screen:

rim-shot

Signing Keys and API Protection

If you read thru the RIM developer guides you’ll see that some APIs are “protected”. RIM wants to protect their devices and users. To do this they do not allow the use of certain APIs until you register and get a signing key from RIM. This costs $20. I guess that’s not too bad, but its a pain because it takes several days to get the keys back. You can register on the RIM site to get a key. There’s also a piece of software you’ll need once you get your key. You take the key RIM gave you and “sign” your app so that when it loads up on the phone the runtime will allow it to work. RIM states that it does not restrict or “certify” what you are doing, the key really just makes certain that RIM can come and find you if you are being “bad”.

Unfortunately Bluetooth is a protected API so I’m stuck till I get my keys. For now I’m going to play around with the samples. If all goes well I’ll be back.

RIM Links:

2 Comments

  1. Java Programming

    Along with track ball style navigation tool, RIM added bright and large screen to this Pearl, that would turn heads for many people. Java Programming

    Reply
  2. berenerchamion (Post author)

    True – in fact that’s the model I have. I was just being a little lazy and used the wrong simulator. My next post I’ll use the right simulator and actually post a screen capture when the screen shows something. Its black in the current pic because the simulated power saving mode came on. D’oh!

    beren

    Reply

Leave a Reply