Detecting BlackBerry JDE Version

Recently, I went back and added some preprocessor code (it’s pretty much necessary in the world of J2ME) to ensure that Hecl would compile with older versions of the BlackBerry JDE. However, I also faced a problem: how to figure out what version of the JDE we’re using. It could be my latest cold clouding my mind, but I couldn’t find a simple way to do this. It never seems to be simple with the BlackBerry platform, unfortunately.

I did, however, finally find a nice way to obtain this information programmatically: the bin/rapc.jar file, which ships with the JDE, contains a file called app.version, which, indeed, contains the version of the JDE in use. I hacked up this code to read it and print it out:

File Selector for Java ME

I recently did some work to make Hecl read files, which also means that it can execute Hecl scripts from the phone’s memory. This is especially important for environments like Blackberry, where we will be distributing a signed version of the Hecl application. To create your own Hecl applications, instead of simply replacing the script in the .jar file, you can point to a script on the device’s file system. This is also available for normal Java ME phones, but unfortunately, for an open source project, the cost of a code signing certificate are prohibitive (on Blackberry, it’s only $20, so I bought one with my own money).

In any case, as part of this effort, I developed a very simple ‘file browser’, which is used in Hecl to select a script to execute.

The results are, like all of Hecl, available under an Apache license, which means that you can use it pretty much wherever you want:

Of course, if you spot any ways to improve it or fix problems with it, I’d appreciate it if you sent patches back.

Open Source Infrastructure?

What’s your opinion?

I’m considering moving the Hecl project to something a bit more modern in terms of infrastructure.

My rough idea is:

  • The web site stays at

  • github for version control

  • Google Groups for the mailing list.

  • Google Code for the bug tracker. Or is github’s up to snuff at this point?

I don’t need much – Hecl isn’t a huge project in terms of code or number of committers, but SF is starting to feel a bit… “creaky”, so I have started thinking about alternatives, even if we’re in no hurry to jump.

Attracting talent to work on the project is definitely one of my biggest concerns. I think that Groups and Github definitely make that easier than SourceForge, but on the other hand, git is fairly new, and I’m not sure how widely it’s used outside of that geeky core that jumps on anything new.

What do you think? Is it going to be more disruptive to switch infrastructure than the gains from slightly more modern systems? Is it worth switching at all? Is it worth trying to use something like Google Code that at least groups most of the bits and pieces together? If you found it worthwhile to move away from SF, what was the “breaking point” for you?

Android Scripting

This is cool to see, even though it will doubtless take away some market share from Hecl:

Importantly, I think it helps to establish that Android is the phone OS for those who want to be able to hack on stuff. With the Apple phones, you’re not supposed to even run interpreters on them. Yuck.

In any case, I think that it still leaves some space for Hecl:

  • Their system uses natively compiled languages that use a JSON RPC system to talk. This makes managing them a bit trickier – Hecl is written entirely in Java and compiled as a ‘native’ Android application.

  • Hecl is very easy to embed, and doesn’t carry around a lot of baggage.

  • Hecl is small – apparently this system clocks in at something like 12 megs! Hecl is something like 500K.

Another cool thing is that this is, like most everything that Google has done with Android, open source under the Apache license (the same one as Hecl), which means that if I get a free moment, I’ll try grabbing some of their console code and integrating it to make a nice Hecl console for Android.

Hecl – for Quilting!

Looking through the logs for, I found this site:

Which, according to the translation is a discussion on a German site dedicated to patchwork quilting about calculating the right lengths to cut triangles of cloth.

I thought it was really cool to see – not because I’m interested in quilting, or the program is anything brilliant (it’s simple and functional), but because enabling stuff like this is part of what I built Hecl for: to make mobile phone applications easier, quicker, and simpler to create. Someone went and typed in the code on Heclbuilder, got the program running, and now a number of people have a handy tool to do some calculations for their hobby, which is a heck of a lot easier than fooling around with SDK’s, Eclipse or Netbeans, and so on and so forth.

I hope to see more of that sort of thing in the future.

Adding callbacks to Android Hecl

Since I recently added sensor callback support to Android Hecl, I thought I’d write about the process of doing so. It’s really pretty easy.

Ideally, it would not be necessary to write and compile any Java code to create callbacks in Hecl – you could do it all inline. However, I don’t think this is possible at the current time with Android’s bytecode engine, although I could be mistaken. It would be necessary to generate a class, or hang some new methods on an existing class. So, for the time being, we do it the old fashioned way whenever anyone wants a new callback to utilize:

The heart of the matter is this class:

public class HeclCallback implements
          android.view.View.OnClickListener {

Which as you can see, implements the various Java listener classes. Each of these requires one or more methods to be implemented in order to receive the actual callbacks. Generally, they are done like so:

public void onItemSelected(AdapterView parent, View v, int position, long id) {
try {
    Vector vec = ListThing.get(script.deepcopy());
} catch (HeclException he) {
    Log.v("hecl onitemselected callback", he.toString());

Which is pretty simple as well: the objects that are passed in are wrapped up as Hecl Things, and then the command is run.

The command to use is set from Hecl like so, when we create a new instance of the HeclCallback class:

set callback [callback -new [list [list SelectDemo]]]
$lview setonitemclicklistener $callback

So, the steps are:

  1. Add an “implements” to HeclCallback.
  2. Define the methods that need defining, copying one of the existing methods.
  3. Recompile
  4. Use the ‘callback’ command to instantiate a new HeclCallback class with the command of your choice as the handler for callbacks.

Hecl on the G1

Thanks to Neal McBurnett, Hecl for Android finally got to run wild and free on a real phone. There were some glitches, but by and large, things seem to work, which is always exciting, and something of a relief. Neil says it runs fairly quickly, and looks good. Once again, a big thanks to Neil, and now on to fixing the bugs!

Android itself continues to evolve:

Now, if only I could get ahold of one of those dev phones! Although, truth be told, I think the “G2” or whatever it is, will probably be a significant improvement in terms of fixing up some of what needs improvement over the first generation, so I’ll probably wait until sometime next year and get one of those.