My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://kavachai.com
and update your bookmarks.

Wednesday, June 17, 2009

Setup Eclipse for BlackBerry Storm development

I've spent many hours trying to install BlackBerry plug-in v4.7 (needed to develop for Storm) on Eclipse and finally I found solution. As always solution was in one small detail. Here is the whole way to setup environment.

INSTALL J2SE
Download and install Java SE Development Kit. Personally I used JDK, but I think JRE should work as well.

INSTALL ECLIPSE
Download and install (actually unpack) Eclipse IDE for Java Developers if you don't have one. I must say that BlackBerry plug-in for Eclipse contains this IDE, but who knows what version did they pack into plug-in installer.

DOWNLOAD COMPLETE ECLIPSE SOFTWARE UPDATE
Once you checked that your Eclipse is working you need to install BlackBerry Eclipse plug-in. Go to BlackBerry JDE Plug-in for Eclipse and download Full Installer and Eclipse Software Update for the BlackBerry JDE v4.7 Component Pack.

INSTALL ECLIPSE BLACKBERRY PLUGIN
Install plug-in from Full Installer first. It will ask you to install new Eclipse or specify existing one. Just point to your Eclipse folder and proceed installation process.
Since Full Installer does not provide you with Storm emulator and v4.7 platform you need to install v4.7 Component Pack. RIM web site suggests to install this update using update site. Don't do it. If you already tried to go this as discribed in instructions you will need to perform step 4. Here is correct way to install update:
  1. 1. Run Eclipse
  2. 2. Go to Help > Software_Updates
  3. 3. Switch to Available_Software tab
  4. 4. Make sure that you don't have a link to "http://www.blackberry.com/go/eclipseUpdate" there. If you have follow step 4.1 otherwise jump to step 5.
    • Remove link to RIM update site using Manage_Sites button.
  5. 5. Add new site like this:
    • Click Add_Site button.
    • Click Archive button and select update file downloaded earlier.
    • Click OK.
  6. 6. Check this new node in the list of available software and click Install button.
  7. 7. Follow instructions in installer.

SETUP ECLIPSE TO USE BLACKBERRY 4.7 JDK
Now you will have 4.7 installed, but not set as default. You need to change default component from 4.5 to 4.7.
To do so you need to:
  • Create new workspace and add BlackBerry project (File > New > Project and pick BlackBerry project).
  • Go to BlackBerry > Configure_BlackBerry_Workspace in Eclipse main menu.
  • Navigate to BlackBerry_JDE > Installed_Components
  • And change component from 4.5 to 4.7

That's it. Now you can start playing with Eclipse environment for BlackBerry.

P.S.
There are some problems with simulator under Eclipse. I wrote about this in BlackBerry simulator in Eclipse could work better.

There is no "enum" keyword for BlackBerry

In one of projects I'm working on I needed to port some code from Android to BlackBerry platform. As part of implementation for Android I used enumeration.
As I saw there is no "enum" keyword for BlackBerry. That was hard to understand since I like enums as a natural way to group constants. Anyway I had two options: use simple constants or design a class. I decided on the second one.

So for enum that looks like this:
enum Numers {
Odd, Twin;

public int toInt() {
return (this == Odd) ? 0 : 1;
}

public static Numbers fromInt(int value) {
return (value == 0) ? Odd : Twin;
}
}
I used class like this:
class Numbers {
public static Numbers Odd = new Numbers(0);
public static Numbers Twin = new Numbers(1);

private int _value;

private Numbers(int value) {
_value = value;
}

public int toInt() {
return this._value;
}

public static Numbers fromInt(int value) {
return (value == 0) ? Odd : Twin;
}
}
Not so natural as with "enum" keyword, but good enough :)

BlackBerry simulator in Eclipse could work better

Yesterday I finally installed BlackBerry plug-in for Eclipse, but I'm disappointed by simulator integration with IDE.

For some reason BlackBerry simulator does not do it's best when developing using Eclipse. Most of the time I cannot run application twice from Eclipse. I have to restart simulator for second attempt to run my app.

It takes some time. So I found a faster workaround. When I see this kind of problem I:
  • rebuild project (Alt+B)
  • manually delete application from simulator (Select app in Downloads; Menu > Delete; Click Delete to confirm)
  • manually load application to simulator (File > Load_Java_Program from simulator menu)

This is much faster then restarting simulator every time problem occurs.

Unfortunately this works only when I don't need to debug code. I still have to restart simulator when debugging.

Thursday, June 11, 2009

External web camera can break your VMWare

Be careful with web cameras and VMWare. This string I needed to buy and install web camera since my laptop doesn't have one. And this simple step led to problems with using VMWare Workstation.
Luckily there a simple fix for the issue found at VMWare Communities:
1) Dont play or install any VMware Software.
1) After installation search for FixCamera.exe and delete it. (generally installed in folder Windows).
2) Run msconfig (I have Windows XP SP2) and in the Start tab, uncheck FixCamera.
My Web Cam's software still works fine without FixCamera.exe

Monday, June 1, 2009

Funny and scaring usage of exceptions

I've just read post The Greatest Exception Handling WTF?!? of All Time.
It's about missusing exceptions in application code. Guy uses exception to return value from method, but usage of this method is even funnier:

the page code that uses the method actually requires the the returned exception to be thrown in order to fulfill its normal function.