Friday, October 31, 2008

Midlets on the iphone

iPhone doesn't natively support Java / J2ME. However as a J2ME developer there are two good ways to develop iPhone applications using Java / J2ME. Read below for details and also to know how you can upload, compile and run Java applications on iPhone.


alcheMo for iPhone contains translator to convert J2ME application source code to equivalent C++ source code for iPhone.
No manual adjustments to the translated source code is required. Compiled using the standard Xcode toolchain and linked with alcheMo's optimized run-time library, a native iPhone application is produced.
alcheMo for iPhone is capable of converting J2ME applications utilizing an extensive subset of Java ME CLDC 1.1 and MIDP 2.0 (including touch screen support) and supports several JSR extension APIs including the JSR-256 mobile sensor API. This automatic translation process is instantaneous, repeatable and doesn't require iPhone specific experience.
Garbage collection and automatic memory management is one of the strengths of the J2ME environment. Unlike on Macintosh OS X, Objective C on iPhone does not support garbage collection. By incorporating an advanced garbage collector, alcheMo eliminates the need for manual memory management. Whole classes of common programming errors such as dangling pointers are thus prevented.
The initial version of alcheMo for iPhone is optimized for mobile games.
The bad news is that their beta program has closed on April 24th, while they are preparing for commercial release. alcheMo for iPhone has backing from Sun Microsystem.
BTW: During Java One 2008, Sun officials repeatedly mentioned that they successfully ran Java on iPhone but are thwarted only by Apple's licensing restrictions in publicly announcing it. alcheMo circumvents Apple's licensing restrictions with their language translator.

2.Using Java on Unlocked & Jailbraked iPhone with Installer

First you need to unlock and jailbrake you iPhone. You can use the windows user interface for ZiPhone to jailbreak, unlock and activate any verion of iPhone.
Then you need to have the installer app on iPhone. is a UIKit based package manager for the iPhone. It works by downloading packages over WiFi (wireless networking) or EDGE. It supports installing, updating and uninstalling applications from multiple sources.
winpwn can simplify the above steps for you.
Now go to Installer and install Mobile Terminal and Cydia Installer. Restart iPhone.
Run Cydia Installer and go to Java section and select iPhone/Java which will install the virtual machine, libraries etc. Then install Jikes (java compiler). Now restart iPhone again.

3.Load, compile & run Java applications on iPhone

First install Java on iPhone following instructions in the section above before reading this.
You can upload Java files to iPhone using iPhone Browser.Run Terminal (installed above) and use java (jikes) compiler to compiler your program. For example:jikes -cp /usr/lib/rt.jar
You can run the class file as usual:java MyFirstJavaProgramForIPhone

4.Apple iPhone and Google Android Introduced to the Market

One of the greatest strengths of Mojax is the fact that it will work on BREW and J2ME, two platforms that are so completely different from each other that developing or porting any application to them requires at least two development teams. Conversely, a Mojax Moblet created once (in a fraction of the time), will immediately run on both BREW and MIDP without ANY additional work. The introduction of the iPhone and soon Android devices into the market only further adds to the overall entropy in the mobile application space. Android, being Java-based, is the “easier” of the two new platforms to support; but iPhone is likely to be Objective-C based which will again require a separate development team to support. I have put the iPhone and Android on the Mojax roadmap for 2008 along with Windows Mobile.