Friday, May 14, 2010

NetRexx on the iPhone

NetRexx on the iPhone works fine. This is what one should do to make it work:

(1) Jailbreak an iPhone. This is necessary until a more sensible setup is used. I used Spirit; it synchs the phone with the hack and then Cydia is installed, an application that does package management the Debian way
(2) Choose the "developer profile" on Cydia when asked. This applies a filter to the packages shown (or rather it doesn't) - but you need to do it in order to see the prerequisites
(3) OpenTerminal will help you to do command line operations on the phone itself
(4) The prerequisites are a Java VM (JamVM installs a VM and ClassPath, the open Java implementation) and Jikes, the Java compiler written in C and compiled to the native instruction set of the phone, which is ARM.

The phone can also be logged on to using ssh from your desktop. Do not forget to change the password for the 'root' user and the 'mobile' user, as instructed in the Cydia package.

When this is done, NetRexxC.jar can be copied to the phone. I did this using 'scp NetRexxC.jar mobile@' (use the password you just set for this userid) (and because my router assigned to the phone today). I crafted a small 'nrc' script that does a translate and then a Java compile using jikes (and I actually wrote this on the phone using an application called 'iEdit' - nano, vim and other editors are also available but I found the keyboard scheme to type in ctrl-characters a bit tedious - you type a 'ball' character and then the desired ctrl char, while shifting the virtual keyboard through different modes):

java -cp ~/NetRexxC.jar $*

Now we can do a compile of the customary hello.nrx with './nrc -keep -nocompile hello' (notice that this is all in the home directory of the 'mobile' user, just like the jar that I just copied. The resulting can then be mv'ed to and compiled with 'jikes'. This produces a class that can be run with 'java -cp NetRexxC.jar hello'

I am sure I will streamline this a bit, just as I am sure I will do most of my builds on the Mac and just will send over the resulting class files. Some study is needed how to address the iPhones content - it seems possible to use the Sqllite data structure the phone uses, and there might be a glue layer to address the GUI - there is for Python. I will keep you posted when that happens.

Please take note of these notes:
Note that jailbreaking an iPhone is against your eula (well - Apple's eula) and might be illegal in some jurisdictions. You might want to live in a country where you can actually do what you want with the equipment and software you paid for. Note that the jailbreaking process does not perform flawlessly every time and that indeed I had to restore the iPhone after the first failed attempt; the next attempt went smoothly. Note that this is a technology demonstration and that I actually use another iPhone to make my calls on and organize my life with. Note that I find the restrictions on the usage of programming languages imposed by Apple to be ridiculous, but I trust them to come to their senses quickly, like they did with introducing the SDK.

1 comment:

Anonymous said...

Yeah but when is Netrexx actually going to be opine source?