RIM (Research In Motion) BlackBerry JDE on Linux

I got a Research In Motion BlackBerry 7520 recently, and started looking around for few usefull utilities. Well, primary thing for me was SSH, and MidpSSJ turned out to be a wonderfull solution. And, what's important, it provides RIM BlackBerry OTA install package. Great. Next in line was IRC client. There are few out there: WLIrc, jmIrc, and few others. So I get one, and try to upload it to my BB. 907 Invalid JAR. Hmm... Let's see.. I get the source, get sun j2me SDK, and recompile everything myself, as MIDP-2.0 midlet (original jar was MIDP-1.0). No luck. I go and do more research. After some digging I figure out that I really need RIM's BlackBerry JDE to produce .cod files that will run BB. I go and grab it. Of course it only runs winblows. Below is copy of few of my posts to BB fora, related to this issue.

Well, I tried wine from CVS yesterday, in win98 mode, installed native M$ Windows Installer 2.0 and was able to install blackberry JDE like this:

WINEDLLOVERRIDES="msi,msimsg32,msisys,ole32,oleaut32,rpcrt4=n" wine ./JDE_4.0.exe

Once installed, I was able to use native Linux blackdown JDK to run main JDE program
(take a look at "jde.bat" in bin directory to get an idea on how to run it).
However, in order to actually compile something you'd need to be able to run "rapc" compiler.
And that is a windows executable. Well, so it seems from the first glance at least.

In reality of course it is just a wrapper around rarpc.jar (found in bin/ and/or MDS/classpath/).
Main class is net.rim.tools.Compiler
so one can start compiler like this:

java -jar $RIM/MDS/classpath/rapc.jar

Problem is that it takes few options, which are obviously not documented anywhere, that
tell it where blackberry runtime is, and which I didn't figure out yet.

Once that is figured out, all we'll need to, will be replacing rapc.exe with rapc.sh
(either replace the file, or edit the resource file that tells JDE where compiler is)

Oh, also rapc is looking for preverify program, which you can get from Sun J2ME SDK.

so, whole invocation will look something like this:
PATH=$PATH:$HOME/WTK2.2/bin java -classpath $RIM/MDS/classpath/* -jar \
  $RIM/MDS/classpath/rapc.jar *.java

(again - this won't work yet - it will complain that we don't import blackberry runtime,
and I still don't know how to deal with it)

--------------------

So, there is absolutely nothing special about running the cod compiler.
I have jmIrc running on my BB now.

here is the sequence of actions:
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.

That's it folks!

P.S. Of course - running emulator and all other stuff will require more work,
but I personally don't care enough for now.

Conclusion

One doesn't really have to go through the pain of setting up JDE through wine in order to compile some generic midlets. All you need is rapc.jar and net_rim_api.jar from JDE/MDS (the ones in bin/ and lib/ directories may or may not work.