Blackberry Rapc gotcha


Once again I bring you a tip from the depths of you won’t find this nowhere on the internet. I tell you, to figure this stuff out you gotta trial and error to you bleed or sleep with somebody that knows somebody from RIM. So you’re running the rapc compiler right? (For those of you that don’t understand the lingo rapc is a program that creates Blackberry installable software from Java program files. You only have to be taller than this bar to use the tool.) You run the compiler and now you wanna know where’s all the extra RIM attributes in your jad file. I mean, they were just there a minute ago and now… no matter what you do, you can’t get them back! That’s what happened to me this morning. I was like, “I’m missing RIM attributes in my jad, SignatureTool.jar dropped the ball man!” But it wasn’t SignatureTool that was responsible. It was rapc!

Here’s the secret: you can’t run the compiler in the same folder as a jar with the same name as your midlet (the name you use with the -midletname flag). In short, rapc won’t overwrite an existing Jar. This and many other Blackberry compiling goodness will be made available as I work on improving the Blackberry build experience. That’s all for now keep yer browser locked…

Blackberry As Modem For Mac


I don’t have time to figure this out completely so I’m just gonna post a link. I’ve been wanting to tether my Blackberry to my Mac (or is it the Mac to the Blackberry?) to access the net but I can’t seem to get a straight answer. According to a pro on the Sprint forums you need your NAI? The phone is company owned so I don’t know how to get this info. But I’d sure like to try. Once again, shamelessly inlining:

To use a Mac with Phone As Modem support, you will need specific information to use the handset as a modem device. Among this criteria is the number to connect to the Sprint Network, and a username / password.

Your username (as provided in the Internet Connection settings through OS X) is your NAI. Your NAI is your Sprint email address for your phone. This is typically username123@sprintpcs.com.

You can find your NAI by going through the settings on your handset. The typical menu path on your Sprint handset to get your NAI is:

1. Settings > Phone Info > My Phone Number (View) > User Name — When selecting User Name, you will be given your NAI. It will follow the name pattern above (usernameXXX@sprintpcs.com) where XXX is a number.

2. You will need the Phone number to connect to. To access the Sprint Network, you will use #777 for the phone number on your phone.

PLEASE NOTE: If you do not have an applicable data plan, you will be charged data usage, so ensure you have an appropriate data plan for your type of use. Also, depending on your market (EVDO, vs Non-EVDO) connections speeds will vary. Instructions for pairing your handset via Bluetooth will be provided in this thread as well. In a situation with a handset like the RAZR2, where a data cable is NOT provided, you can pair wirelessly with your Mac using Bluetooth, eliminating the need for a cable. Bluetooth is standard on all MacBook, Macbook Pro, and the MacBook air laptop. It is also standard on all Intel based Mac Minis and the iMac. The Bluetooth pairing will allow you to not only use the handset as a Phone as modem, but also use iSync to link your Calendars and Contacts with you handset provided you have the appropriate iSync plug-in for your phone.

Compile And Sign Blackberry apps on a Mac With Maven!


It’s Friday night and I finally found the answer to the last part of my SignatureTool.jar problem. See this post here that I will shamelessly inline for the fear of losing it to a random blog crash or deletion. The wonderful developers at Rim have never developed on Linux or Mac before. So they use backslashes in their path references! In short the post to download the ClassEditor software to poke around and change the values in the constant pool. (Get ClassEditor here then continue with the rest of the instructions.)

extract it, and run it with the command:
java -jar ce.jar

Open two class files extracted earlier: q.class and ad.class. ClassEditor will look something like this:
screenshot-classeditor-0.png
ClassEditor with q.class and ad.class

Start with q.class and select the Constant Pool tab. In this file we need to change string constants containing just a single backslash character. There are actually two constants in the pool but the first is just a reference to the second. The string we want is at index 223.
screenshot-classeditor-1.png
String constant at index 223

By default ClassEditor starts in read only mode so click the bright green Modify Mode(Off) button in the top right. The fields in the details area are now editable. Simply change the forward slash to a backslash and click Modify. Click save and that’s it for q.class!
screenshot-classeditor-2.png
String constant 223 modified

Select ad.class on left and locate constant 117, again in the Constant Pool tab.
screenshot-classeditor-3.png
String constant at index 117

Change the value from \sigtool.set to /sigtool.set and click Modify. Click save and that’s it for ad.class.
screenshot-classeditor-4.png
String constant 117 modified
Repack SignatureTool.jar and test

To repack SignatureTool.jar just cd to the temporary directory where you extracted the jar and rejar the class files
cd ~/lib/RIM43/bin/tmp
jar -cmf META-INF/MANIFEST.MF ../SignatureTool.jar *

Go up one directory and remove the temp directory
cd ..
rm -rf tmp

To test that everything worked, just run the command
java -jar SignatureTool.jar

If should prompt you to locate a cod file. Just cancel this and click the Properties button in the main signature tool window. If you see a list of Registered Signers it worked!

I followed the above with my copy of the SignatureTool.jar from the 4.2.x JDE and it worked flawlessly. After patching the SignatureTool.jar I repackaged it with the signature.csk signature.db and signatuer.set files and deployed it to our internal repo. The plugin I was working on now works without problems. I wanna stay up and work on this a little longer. I think I’ll put this post up on Monday.

I got it!


I just ran the Blackberry compiler from Maven… on my Mac. Two cans of Pabst Ice and one Mike’s hard cranberry lemonade into my dev cycle and I finally see a “.cod” file show from a pyx4Me project! It’s in the wrong folder, project root vs. projectroot/target but I can live with that for now. Anyone know a groovy way to set the working directory from a command string run by the overloaded String.execute() method? I don’t wanna call out to Runtime.exec and I don’t wanna write a bunch of platform checks in my plugin. Right now I’m one too many drinks swallowed to know whether or not String.execute() implies platform. In other words I don’t know if I need to code a prefixing “cmd /c ” on my string and check for Windows before calling String.execute(). I’m not happy with the impl because there were a few things I wanted to do better. Right now I’m spawning a java process because the GMaven plugin doesn’t set the rootLoader, which means I can’t dynamically append to my classpath. I’ll either have to set the rapc.jar as a dependency or figure something else out. I’m just glad I got this far! More updates later…

Build Native Blackberry apps natively on a Mac… using Maven!


Click here for the Maven Blackberry code behind this post.

Aight, I can’t help it! I’ve been itching to get this done for sooo long. If you’re into Blackberry development then you’ll understand just how absurd the above title sounds. Let me just throw intelliJ Idea into the mix as well then you’ll begin to see the big picture. Starting to do J2ME development, an experienced Java guy like myself has naturally gravitated towards a certain set of tools. Maven2 is hands down the only acceptable build system for a Java project, while Idea beats the pants off of Eclipse, and Windows boxes…? Forget it! Java runs practically double speed on a *Nix OS plus with the flash of OS X there’s no question as to what boots on a typical knowledgeable hard working Java developer’s box. All of these tools work well, and most of them work well together. BUT… BUT!!! Doing J2ME implies Windows and Ant all around so there’s gonna be either a divorcing of the toolchain or a boatload of integration issues. This weekend I fought through the biggest of the integration issues. And this morning I finally managed to build a Blackberry .cod deployable program… completely without Windows… using a Maven2 pom… natively on my Mac! I’ve been updating my blog incrementally with all of the individual pieces so I won’t go into too much detail here. At a high level I’ll explain the tools involved.

  • One Apple Macintosh (iBook, MacPro, MacbookPro, MacAir, whatever…)
  • One Blackberry (Preferably not Verizon because I don’t think they support J2ME)
  • One Windows install (I know, but this is only to extract the Blackberry tools! You can throw the whole thing away once you got the goods out of the JDE downloads. If you have a buddy that already has the JDE just steal it from him and skip this piece all together.)
  • One install of the Blackberry Java Development Environment (JDE).
  • One bottle of scotch (or wine) for to celebrate with.
  • One install of Maven2
  • Two tablets of asprin (to handle the hangover after you’ve spent the entire rest of the day celebrating with scotch or wine.)

I think that’s everything in the ingredients list. I’ll post back later with the recipe as time allows.

Didn’t get far


I was trying to develop J2ME with Maven on my Mac and blogging about it at the same time this past weekend. As an update I didn’t get too far. Fow what it’s worth, I did get a jar to build and I was able to manually upload it to a web server and then install it on my phone. The app worked but I still need to work out the kinks in automating the deployment process. I’m not sure if my Blackberry supports bluetooth installs and if it does I can’t find any documentation on it anywhere. On my drive in this morning I got to thinking about going the rest of the way and building a Blackberry plugin for Maven, one that would execute rapc and SignatureTool. I’ll have to prototype that from the command line first. More on that later. Back to regular work for now.

Run Progaurd Preverify os OSX?


Last night I went heads down researching and trying to figure out how to get passed the infamous preverify hurdle when building J2ME apps on OS X. I’m happy to report that I’m an idiot. I went through a boatload of trouble finding and almost attempting to fix a bug in the Antenna preverify task as it is slightly broken on OS X. I emailed everyone I could think of who had anything to do with Antenna, the Maven2-J2ME-plugin, and OS X. I submitted to blog posts along the way as I worked. Just moments ago I found what looks like a much more simple fix. The Pyx4ME project includes support for Progaurd which now includes a preverifier! I completely overlooked this option as I waded through mounds of documentation al from different sources regarding the best way to get past preverification on OS X.

I just ran a build with the Progaurd preverify option and it succeeded! I haven’t tried to run it or anything… that step comes next. I’m all too excited to see something actually run all the way through on my Mac.

I must admit that I’m slightly hesitant to take this approach due to the frailties our team has found with build time tools for J2ME. I’m speaking about issues with different JVMs, different obfuscators, too many obfuscators, lack of obfuscators, preverify configuration, application signing methodologies, and every other flaming hoop you have to leap through to get a decent build for a single device. I’d go into detail but I wanna keep plugging away to see how far my insanity can carry me.

Run WTK preverify on OSX!


In other breaking news I found a possible way to do true cross platform WTK development. If you’re not familiar OS X is the one platform where you really can’t do JavaME unless you’re really really savvy! The missing too is preverify. (An intel Mac compatible version can be found deep in the bowels of the PhoneME source download.) There’s the ol’ MPowerplayer preverify tool but that’s a little dated and out of synch with the WTK preverify tool. As a result you’ll find tools such as the EclipseME and Pyx4ME plugins won’t work with it. (Actually I believe EclipseME has Mpowerplayer support but I haven’t tried it.) I’m gonna keep this short so I can work on it. There’s this cat that’s blogging about doing cross platform JavaME development and I’m reading the blog now. On the blog he explains that the preverify tool in the PhoneME MR2 download under phoneme_feature/cldc/build/share/bin/darwin_powerpc/ will run on an Intel Mac. I just tried it on my 2.4Ghz MacPro running Leopard and I was able to bring up the help text from the command line. I’m loosely following his write up and a few other tutorials and links in an attempt to create a deployable Blackberry J2ME project using Maven on my Mac. We’ll see how far I get.

Run The Blackberry Compiler on Linux


Run rapc on Linux? Rapc for Mac? BSD and rapc?

Seriously, is this possible? I’ve been wondering for a while how feasible it would be to do J2ME development full time on a Mac or Linux machine and I dunno… it sounds reasonable at times and far fetched at other times. Today I found this gem. A guy supposedly got rapc, the Blackberry compiler, to work on a Linux machine. I’ve personally managed to sign Blackberry apps without requiring a full JDE install so maybe this is the other half of what I’ve been looking for? Here’s a shameless copy from the forum, in case it ever get deleted or lost:

1. Compile normal midp-2.0 midlet with J2ME SDK from Sun
2. set up $WTK_HOME to point to your J2ME install, $RIM to point to
your JDE/MDS/classpath, and $APPNAME to your app name
4. cd to $WTK_HOME/apps/$APPNAME
3. run
PATH=$WTK_HOME/bin:$PATH \
java -jar $RIM/rapc.jar import=$RIM/net_rim_api.jar \
codename=$APPNAME -midlet jad=bin/$APPNAME.jad bin/$APPNAME.jar

Your .cod file will end up in current dir. bin/$APPNAME.jad will be modified to contain all
BB-specific info.

I’m looking to do something with this knowledge. I’ll post back if I ever come up with something.

8830 + 8010 = Hitz4Dayz!


I mentioned my new Jabra toy a while back and I’ve been meaning to include a follow up post on it. Ya’ see I’ve had this company issued Blackberry for a minute now. And I bought one of those SD mini cards, the kind that holds about 1GB but is smaller than the tip of your finger. It was the only way I knew (at the time) to put my jamz on my 8830. I’ve been rapping about MOP for a while I figured it’d be a good idea to hear some M.O.P. once and a while… without teaching my little girls bad words. So that’s where the 8010 comes in. I can put this little trinket on my right ear and stream “Downtown Swinga” Blackberry 8830while my left ear is tuned to the kids… making sure they are well behaved. The device does more than that. It pairs with multiple devices so I can use it to record audio over my screencasts on my Mac. I can also stream audio from iTunes (though for some reason Bluetooth audio from the MacBook sounds like it uses voice audio encoding which makes everything sound like it’s played over the phone… something I’m still trying to figure out….) and take a phone call right in the middle of K.R.S. 1’s “The Bridge is Over” without missing a beat. Well I might miss a few bars because iTunes will continue during my phone call but when paired to Blackberry music automatically pauses for phone calls. Speaking of calls I love the vibrate alert on incoming calls. It takes some getting used to and still makes me jump out my skin on occasion but what an un-ignorable way to announce a call! If you’re too jumpy, like I am, you can disable vibra-alert and save face in public places. (Nothing says “I’m need a straight jacket” louder than a guy paying for a gallon of Clorox Bleach and some M&Ms who suddenly decides to pull his head into his torso “Ninja Turtle” style while jamming both shoulders in his head while some indecipherable blue text appears on his right ear.)

I’ve read that the 8010 includes noise reduction but I don’t know because I’m on the noisy end. I believe my calls come through more clear but I’ve yet heard someone take notice. I don’t make many phone calls anyhow and when I do I’m almost always in one of those Sprint spotty coverage areas. I’ve also heard that it has caller id which is one of the dumbest features I could imagine on such a device. Unless you can fold your face down the center and peek at your ear from one eye I don’t understand how caller id can do anything for you. I still don’t know if mine works. Maybe if you had a girl friend or a wife with an ear fetish you’d have a clue who’s buzzing you but then again, what if you decided to cheat on Mrs. I-Love-your-ear?

The thing I like most about the 8010 is how it plays stereo with the optional attached secondary ear piece. You can stream audio in mono with just one piece but everything sounds so much better in stereo. Jabra 8010Even phone calls come through in stereo. You get that in the machine feeling when you favorite song is cranked way up then you get a call which comes through in surround sound. Tap the button to pick up the call, tap again to end the call, then tap mode then the main button again to resume Reggae ’94.

Paired with an 8830 you get the added benefit of voice dialing. I’ve been in a few situations where I need to join a conference call while driving down Route 30 and not wanting or able to pull to the side. One tap then speak, “call meeting place” give me a friendly voice prompt, “Did you say call Meat and Place?” to which I reply, “Hell no!” The follow up prompt, “Did you say call Me-Jing Prace?” eventually connects me to our conference room (the Text To Speech on the 8830 has some minor pronunciation issue that you learn to appreciate over time). That’s all for now, it’s past my bed time and I need to rest up. If you’ve had some fun with Bluetooth drop a line. I’d love to hear ’bout it.