One of the best aspects of my job as computer science professor is that I keep learning new stuff. This semester, I am teaching a software engineering class. Cinequest, the organization that puts on the annual San Jose film festival, approached the CS department, asking for help with their mobile initiative. We jumped at the chance, and now my students are hard at work designing and prototyping a BlackBerry application for festival attendees.
Our job is to put the festival catalog into the palms of the moviegoers so they don't have to browse the paper version, which is not only uncool but may also be out of date. Why the BlackBerry when everyone (except for McCain's staffers) knows that the iPhone is the cool device to support? Well, the BlackBerry is an open system, and you don't have to deal with Apple which has rather rigid ideas who gets to be a developer and who gets to put apps on the device. Also, fortunately for me, the BlackBerry runs Java. I want to learn new stuff, but not that much new stuff :-)
It is the perfect project for a software engineering class. We have a real customer and a real deadline, but the scope is reasonably constrained so that is feasible. And there is great resume value for the students and PR for the university. Now what we really need is some BlackBerry donations for the students, preferably with some air time tossed in. If anyone has useful contacts, please let me know!
As it turns out, BlackBerry programming isn't quite the same as Java ME. While Java ME apps will run on a BlackBerry, they don't have the same look, so we decided to go with the BlackBerry API.
That is easier said than done. We groaned when we found out that the development tools only run on Windows. (Somewhat to my surprise and delight, half of the students prefer Linux as a development platform.) I feel transported into a different world, where archives are distributed as .EXE files and development done in a (rather poor) custom IDE rather than Ant scripts and Eclipse/NetBeans plugins.
Fortunately, there is an Ant task that works on Linux. (It is pretty sad that one needs to hack one of the tools that has hardwired backslashes, but a good lesson for my students who will hopefully never do such an embarrassing thing themselves.) The only thing that doesn't work is the simulator. Some lucky people can run it in Wine, but not me. If you are among the unlucky, here is how you can get it to run in VirtualBox.
- Install VirtualBox for Linux, using all the default settings. Except, crank up memory. (768K seems to work for me.)
- Start VirtualBox. In the Devices menu, mount the CD ROM. Install Windows XP. (If you are a student, chances are that your department or student club has an agreement with Microsoft where you get an install disk for free.) During the install, enjoy the rather humorous messages on how great XP is going to be.
- In the Devices menu, mount the ISO image
/usr/share/virtualbox/VBoxGuestAdditions.iso. Run the installer in Windows.
- Start Internet Explorer. Download and install JDE4.6.0 from BlackBerry. Launch the device simulator. (You need notinstall Java.) The simulator takes a long time when it is launched for the first time. Afterwards, it is quite a bit better.
- In the VirtualBox Devices →Shared Foldersmenu, share a directory from the Linux host with Windows, e.g.
/home/cay/shared.) In Windows Explorer (and in file dialogs), you can find that directory as My Network Places → Entire Network → VirtualBox Shared Folders. (This does not work in the My Network Places icon on the desktop.)
- Write your BlackBerry app on Linux, build with Ant, move the .COD file to the shared folder, and select File → Load Java Program in the simulator. With the 9000 simulator, the app shows up in Downloads.
First I didn't understand why the simulator wasn't just written in Java. But it is able to simulate Bluetooth, so it may be some amount of work to get it to work cross-platform. Looking into my crystal ball, I would think that going forward, it will be increasingly hard to ignore Linux and Mac OS X in the developer marketplace. Maybe one solution is to treat Wine as another flavor of Windows on which your software must work.
If any BlackBerry hacker reads this, I'd be grateful for a tip on how I can render the tabs on the top so that they don't get cut off. Buttons don't seem to be the right thing, but I couldn't find any tabbed pane in the API.
Finally, here is a cool article by fellow Java Champion Qusay Mahmoud, who uses BlackBerry devices in his CS1 course at the University of Guelph in Canada. (He teaches straight Java ME.)