Now this process isn’t 100% ideal. If you are an experienced developer you probably already know you need four key components.
- Rapc compiler
- Signature tool
- Simulator
- Javaloader
The first two components works fabulously in Linux. The second (signature tool) needs a kick in the pants to work (shame shame shame!).
The third is hit or miss when using Wine. So a less painful option is to put windows in a virtual machine and run the simulator there (more on that later).
And the fourth I just can’t get past. There is the barry project which has made impressive progress in the last few months and lists javaloader support as on the roadmap for milestone 4. RIM, if you have any sympathy for us non-windows users show these guys some love and send them some specs for heaven sakes!
This article presents the basics for compiling, signing, and debugging BlackBerry applications with Linux.
Rapc Compiler
First you need a copy of the JDE or the JDE components package. In my last article I covered a method of extracting the install packages distributed by RIM, but if you have access to a Windows box copying the installed JDE works just fine too.
The rapc compiler needs two external commands:
- Java Compiler (javac)
- Preverification Tool (preverify)
Install the Sun JDK to get javac:
sudo apt-get install sun-java5-jdk
The preverify command can be obtained by downloading the Sun WTK.
chmod +x sun_java_wireless_toolkit-2_5_2-linux.bin
./sun_java_wireless_toolkit-2_5_2-linux.bin
For some reason this package complains it can’t find Java interpreter. If this happens, the Java 5 JDK is located /usr/lib/jvm/java-1.5.0-sun/bin on Ubuntu.
Once extracted, unless you plan on doing vanilla J2ME development, you can copy the preverify tool and then delete the WTK.
mkdir ~/bin
cp ~/lib/WTK2.5.2/bin/preverify* ~/bin
rm -r ~/lib/WTK2.5.2
Don’t forget to put the ~/bin directory in the execution path. To have this set automatically each time you login, put this line in your ~/.bash_profile file (create it if necessary).
export PATH=~/bin:$PATH
Compile “Hello, World!”
I’ll be using Apache Ant for building because it’s the common denominator when it comes to building Java projects (like it or not). Most IDE’s have some level of support for running ant scripts.
Install ant:
sudo apt-get install ant
Download bb ant tools and put it where ant can find it:
unzip bb-ant-tools-0.7-bin.zip
mkdir -p ~/.ant/lib
cp bb-ant-tools.jar ~/.ant/lib
Download the hello world project and run "ant" in the project directory:
wget http://www.slashdev.ca/download/hello.tar.gz
tar -xzf hello.tar.gz
cd hello
ant
Output from the ant should look something like this:
josh@ubuntu:~/hello$ ant
Buildfile: build.xml
build:
[mkdir] Created dir: /home/josh/hello/build
[rapc] Compiling 1 source files to ca_slashdev_hello.cod
BUILD SUCCESSFUL
Total time: 1 second
Signing
To sign your cod files, follow my guide on how to fix the signature tool. Then just run the sign target in the build script.
ant sign
Comments 22
Hi,
I made small patch to the ant task so that you can define the ‘exepath’ parameter that is used by rapc to locate the preverify tool. This way you don’t have to put preverify on the path. Actually quite surprisingly rapc first looks for an executable called “preverify” and only if it can’t find it will check for “preverify.exe”. Having just hacked all those backslashes out of the BB tools it’s a bit surprising
.
The patch adds a new property to the rapc task called exepath. It should point to the directory containing the preverifier. (I know exepath is a stupid name but preverifierpath would have been too long. I guess that’s why the RIM guys chose it
)
You can get the patch from here: http://atleta.dyndns.org:8080/p/opensource/bb-ant-tools/exepath.patch
Let me know if you integrated it. My e-mail address is atleta and the domain name is atleta.hu. Join the two with an @…
Posted 23 Jul 2008 at 9:15 am ¶Thanks atleta,
This patch will be applied to the trunk.
It really is amazing how solid the rapc tool is considering how flimsy the other tools are. I guess for that we should be thankful.
Posted 23 Jul 2008 at 11:19 am ¶Actually, I recently discovered that RAPC does have a slash-vs-backslash problem like the other tools. You just don’t encounter it until you try building resource files into your project. However, it can be fixed with the same techniques outlined elsewhere on this site.
Posted 06 Aug 2008 at 4:59 pm ¶Derek,
That’s funny, I’ve yet to run into that problem. By resources, are you refering to .rrc and .rrh files?
Posted 06 Aug 2008 at 5:53 pm ¶Awesome, but once I set to host mode, my virtual host will not boot
Posted 18 Sep 2008 at 4:56 am ¶Patrick,
Can you expand on that? Does virtualbox fail to start the guest, or does the guest OS fail during boot?
Posted 18 Sep 2008 at 9:35 am ¶@jiGGaK
The guest OS failed to start the guest. I get this:
Failed to open ‘/dev/net/tun’ for read/write access. Please check the permissions of that node. Either run ‘chmod 0666 /dev/net/tun’ or change the group of that node and make yourself a member of that group. Make sure that these changes are permanent, especially if you are using udev.
VBox status code: -3100 (VERR_HOSTIF_INIT_FAILED).
and this:
patrick@berrysoft:~$ ls -l /dev/net/tun*
crw-rw—- 1 root root 10, 200 2008-07-02 05:16 /dev/net/tun
so I did this:
patrick@berrysoft:~$ sudo chown :vboxusers /dev/net/tun
patrick@berrysoft:~$ ls -l /dev/net/tun*
crw-rw—- 1 root vboxusers 10, 200 2008-07-02 05:16 /dev/net/tun
patrick@berrysoft:~$
and now it boots. Thanks for offering to help.
I just had to do a little more man page reading. =)
Posted 28 Sep 2008 at 2:27 am ¶Hi,
I read that barry has indeed successfully implemented the javaloader in trunk.
I haven’t tested it yet but I just bought a blackberry and am very eager to do some blackberrry developer on Linux.
Have you tried the new eclipse plugin? Do you know it that works on Linux?
I’d love to chat more about BB development on Linux! Feel free to send me an e-mail.
Cheers,
Cody
Posted 11 Feb 2009 at 8:27 pm ¶I can’t get your hello world to build at all, regardless of where I put the JDE (4.2.1 or 4.7.0). It fails as follows:
/tmp/test/hello/build.xml:12: jde home missing “lib” directory
Of course, the JDE doesn’t HAVE a ‘lib’ directory at all inside it, nor should it.
How did you build this, if not against the RIM JDE 4.2.1 or 4.7.0?
Posted 12 Aug 2009 at 1:52 pm ¶David,
What does your JDE directory structure look like? Every version of the JDE I have come across has a “lib” directory.
Here is what my 4.2.1 JDE structure looks like:
Posted 12 Aug 2009 at 2:13 pm ¶Well, after installing both JDEs on Windows, and copying over, it replicated the correct structure. I have no idea what happened before, but now I can build the hello sample.
Now off to figure out how to fix the broken SDK, so I can build the Funambol Blackberry client using this same process.
Posted 13 Aug 2009 at 7:13 pm ¶Oh, and thanks for setting me on the right path
Posted 13 Aug 2009 at 7:13 pm ¶sir/ madam
Posted 02 Sep 2009 at 11:17 pm ¶please let me know briefly the application of linux in the industries. is linux an imporatnt language to be learnt.
i am in eager to learn it. learning them is essential is of any industrial importance.
application possible with linux??
Posted 02 Sep 2009 at 11:20 pm ¶i want to know how linux developed &development uing linux
Posted 02 Sep 2009 at 11:25 pm ¶Thank you for the helpful post. Really saved my day.
Posted 08 Apr 2010 at 11:54 am ¶I’m missing something, I installed everything, I could even run the simulator from your other post, but I don’t know where to put the /lib dir from the JDE and when I run ‘ant’ inside hello i get:
BUILD FAILED
~/hello/build.xml:12: jde home must be a directory
Any help would be appreciated.
Posted 06 May 2010 at 5:47 am ¶Thanks
Great post, really!
Posted 19 May 2010 at 2:17 pm ¶It worked for me, but I still have an issue with rrc/rrh files. If I look at the .crb corresponding files generated in the jar, they differ at the and of the name with those generated on windows. I.e. the file names in linux are ca.slashdev.FooApplication?.crb, as they are ca.slashdev.FooApplication-รบ.crb in windows. It must have something to do with caracter encoding, but I can’t figure out how to fix it. If anybody has managed to use localization of resources under linux, please post the fix.
Thx
Figured it out:
Posted 20 May 2010 at 9:01 am ¶export LANG=”en_US.ISO-8859-1″
I have a problem with a project with a lot of .java files (over 1000). At first I had “Create process error=87″ problem at java start. It was solved by adding “generatesourcelist=”true”" flag to ant task. And now i stuck at the similar problem that appears at javac start. It looks like
Posted 30 Aug 2010 at 6:09 am ¶[rapc] I/O Error: Cannot run program “javac”: CreateProcess error=87, The parameter is incorrect. Anyone can help me?
Alexey,
Try searching the bb-ant-tools mailing list. I know something similar to this topic has been covered there before.
http://sourceforge.net/mailarchive/forum.php?forum_name=bb-ant-tools-general
Posted 30 Aug 2010 at 6:32 am ¶Very useful post. For extremely basic results (in answer to some of the queries above) I started in a basic directory of hello. Then mkdir bin and mkdir lib.
Posted 28 Sep 2011 at 11:20 am ¶I copied preverify, preverify1.0, preverify1.1, rapc.exe and rapc.jar into bin. Copied net_rim_api.jar in lib and set jde.home=. (working directory) in the build.properties file.
Then ant builds a jar and jad (and cod). I then bluetoothed jad and jar to Blackberry, and explored Documents Folder via media. Click on the jad and it will install.
This is all just on principle of Good Enough to see if it works and wouldn’t be suitable for large projects or production.
(ubuntu 11.10, Blackberry Curve 9300)
Trackbacks & Pingbacks 3
[...] a previous post I listed 4 key items needed for BlackBerry [...]
[...] http://www.slashdev.ca/2008/04/03/blackberry-development-using-linux/ [...]
[...] an OSX development environment — just Windows — so I’m forced to work through the Linux hacks for doing Berry dev on unix-like [...]
Post a Comment