Programming J2ME on Symbian

image

Since I'm on the topic of J2ME again, I've been meaning to write this and just haven't gotten a chance. Here's a quick post to get it out of my backlog. :-)

A few weeks ago during JavaOne I met up with Edward Kay from Symbian who was kind enough to pass off to me a free copy of Programming Java 2 Micro Edition on Symbian OS. Since I have in the past purchased all of the other Wiley books, including the incredibly useless (unless you have a P800) first book on Personal Java for Symbian (though it doesn't say that), I was quite happy to both get a free book for my previous investment and see that this book concentrates on MIDP instead.

This book is like Michael Juan's Enterprise J2ME in that it's not another introductory to J2ME. God knows there's enough of those around. I mean, it does have the obligatory chapters on getting up and running, etc. but then gets into the meat pretty quickly. And again, it's focused on J2ME, but for Symbian devices - and by Symbian, the book mostly just focuses on Series 60 phones, which is perfect. I love Symbian and Series 60 especially, but hate UIQ. Though I was given a nod, wink and a nudge about the next version UIQ by Ed - I still won't believe it doesn't suck until I have it in my grubby little hands and see it for myself. Much better to concentrate on most popular (by far) version of Symbian.

The book covers a bunch of topics which don't ever seem to get much coverage online or anywhere else including the Messaging API, Bluetooth, the Media API, the security model and more. And there's a chapter on optimization that is very enlightening as well. Example:

The StringBuffer Memory Trap

Working with String and StringBuffer can result in large amounts of memory being used unexpectedly. The problem is this: when StringBuffer.toString() creates a String, the newly created String uses the StringBuffer character array. This means that if a StringBuffer with a 1 KB capacity only holds a 10 character string, the new String will also use a 1 KB character array to store 10 characters. If the StringBuffer is modified, the StringBuffer array is copied in its entirety and then modified. Now both the String and the StringBuffer have separate 1 KB character arrays. We have just lost the best part of 1 KB of memory! Repeating the process will continue to use excessive memory as we generate 10-character strings that use 1 KB character buffers.

See? And there's more like that. Lots of sample code, screen shots, benchmarks and lots of real-world advice and all of it focused on MIDP and Symbian. Very cool. It seems very non-fluffy, though *why* do books insist of having indexes which are essentially badly-done print-outs of JavaDocs? Waste of pages.

I'm not sure if it's available just yet, but if you're doing something with J2ME and S60 phones, this should be a good book to get when it's out. I find myself reaching for it quite a bit lately to better understand exactly how some of the less used or advanced APIs work (like Push Registry). I'm going to be using it again soon to get Bluetooth-to-Bluetooth connections working, a month or so ago when I was playing with that tech I was completely bewildered but there's code samples and everything in the book, which should help quite a bit. Definitely nice to have around.

-Russ

< Previous         Next >