Java Midlets on the Pocket PC - the Complete Tutorial

UPDATE (late 2007): the article is outdated. Read THIS instead.
(end of update, original article follows)

Midlets are widely known for mobile phone users because a wide variety of games, chatter applications (for example, Internet Relay Chat clients), Web browsers (for example, the excellent Opera Mini), Google Maps cients (for example, Mobile GMaps) etc. are available in a cross-platform midlet form.

I always receive a lot of midlet-related questions (see for example this and this threads; note that they're a bit old and, therefore, do not have the most up-to-date information); this is also why I've decided to write an all-in-one article on all the midlet-related questions. (Needless to say, this article is the first generic, practical overview ever written on this question.)

Opera Mini, the best, free Midlet-based Web browser itself is certainly a reason for learning to run midlets on PPC's. While a bit simple and incapable at the first blick (for example, there's absolutely no support for selecting text and copying it to the clipboard – in this respect, it's like the Thunderhawk browser, which doesn't allow for any kind of such functionality either), you'll soon learn to love to use Opera Mini on your Pocket PC because:

  1. It loads pages really fast
  2. It keeps communication costs down by compressing and heavy content stripping – you don't need to use third-party services like Toonel, OnSpeed or Web-based compression/content stripping engines like Skweezer or MobileLeap.
  3. It can keep open dozens of (even large) Web pages without a significant memory/process number hit. With Opera Mini, you can easily keep as many as 30 (thirty) windows open (and easily, instantenously switch between them in Menu/Tools/History). In my real-world tests, 30 big, graphics-intensive pages only occupied about 12-13 Mbytes of RAM (and only one process – most other browsers use separate processes for each opened window, which will result in pre-WM5 operating systems the automatic shutdown of background tasks when you open more than 7-8 windows; with WM5, you can keep slighly more pages open). When browsing in a "real", non-midlet-based Pocket PC browser, you'll soon (say, after 10-12 opened pages) run into the memory / maximal process count constraints of the operating system/the particular device.
  4. It's compliant with most (tested) Web pages, only with small compatibility problems (for example, the Reply/Forward links not working in the full (non-PDA-optimized) Yahoo Mail; this problem, incidentally, also plagues most "full" Pocket PC browsers).

Also, aside from Opera Mini, there're some games and other applications available as midlets. For example, the Reqwireless mailing-related midlets were of really high quality (too bad the company has recently exit business). And, I've already mentioned the Google Maps clients - they work just great on the Pocket PC, unlike Web browser-based ones.

Note that, as far as games are concerned, only generic ones will work. Anything non-generic (machine-specific) will refuse to work. That is, it's pretty useless to download for example Sony-Ericsson or Nokia-specific games – they will not work (before you ask: yes, I've thoroughly tested several phone model/brand-specific midlet games. None of them worked.) This not only concerns commercial titles but also even open-source, free ones like the (Nokia Series 60-specific) Bomber.

What Midlet environments are available for the Pocket PC?

intent Midlet Manager (intent MM for short) is by far the best midlet environment for the Pocket PC. It comes pre-installed on all known HTC Phone Edition Pocket PC's – and even some non-HTC (but, still, HTC-manufactured) ones like the iPAQ hw6515.

Unfortunately, there're no separate intent MM downloads and you can't hack the intent MM extracted from one device to another (I've tried it really hard). That is, you will only be able to use it on PPC PE devices.

Also note that older (still PPC PE) versions of intent MM can't be installed on arbitrary devices. For example, I've tested version v10.1.2.57 without any success.

I also recommend the XDA-Developers search page with the expressions 'intent', 'midlets', 'midlet' and 'tao group' – you'll find a lot of additional, albeit pretty-hard-to-digest information there.

It's also worth knowing that in most WM5 PPC PE models (for example, the HTC Wizard (i-mate K-jam, Qtek 9100, MDA Vario; the only exception is the T-Mobile MDA, which does not contain the intent MM)) the ROM itself contains intent MM; that is, it's not installed from the Extended ROM. When you do not let, after a hard reset, the Pocket PC install the contents of the Extended ROM (Skype in most distributions, some kind of totally useless firewall-/antivirus in early ROM versions, i-mate Backgammon in i-mate ROMs etc.), the intent MM will still be present. Nevertheless, there will be no direct icon to it in Start/Programs to access the MM. To fix this problem, just get and copy this file (make sure you right-click it and choose Save Target As from the context menu!) to \Windows\Start Menu\Programs on your PDA.

Finally, if you look around in the JBenchmark MIDP1 and MIDP2-related benchmark pages (here and here, respectively; make sure you use the default, 'by score' sorting), you'll see that, particularly in the MIDP2 speed tests (in MIDP1 tests, Palm OS devices are generally faster), intent MM beats everything else – even mobile phones meant for gaming.

WebSphere Everyplace Micro Environment MIDP 2.0 5.7.2 (IBM J9 for short) is clearly worse and weaker (slower and less compatible) than the intent MM. Note that it's WM2003+ only (no pre-WM2003 versions are available) and is fully compliant with WM5.

Finally, NSICom's CrEme 4.1, the best overall Pocket PC generic Java Virtual Machine, is also able to run simple, non-networked midlets. It's, however, really restricted and is, therefore, not recommended at all for anything serious – even IBM J9 is better. Please read this article for more information on this matter. (Nevertheless, in this article I also provide information on using CrEme with midlets.)

Note that the midlet-related situation may be changed in the future in CrEme - I hope so.

Also note that the otherwise decent Pocket PC Web browser NetFront doesn't support midlets. Please see the section "Addition" at the end of this article.

Benchmark results – comparing the available midlet managers

If you run the de-facto standard midlet manager benchmark, JBenchmark (note that you should only get JBenchmark and JBenchmark2; none of the available Pocket PC midlet managers are able to run the advanced JBenchmark3D or JBenchmarkHD midlets; CrEme can't even run JBenchmark2 because CrEme is not even MIDP2.0-compliant), you'll see some very strange numbers claiming J9 is far faster than the intent MM. (This will be the case on most Pocket PC's, except for for example the Fujitsu-Siemens Pocket Loox 720, where it runs really-really slow – much slower than some other VGA devices, for example, the Dell Axim x51v. The latter runs the benchmark midlets almost as fast as QVGA Pocket PC's.)

Some numeric JBenchmark results I've measured on my HTC Wizard, under exactly the same circumstances:

Midlet Manager:Intent MMIBM J9CrEme 4.10
JBenchmark4950, 5068 (two tests)31894, 32067 (two tests)1303
JBenchmark2486, 4991618-
JBenchmark3D---
JbenchmarkHD---

Don't trust these numbers. For example, J9 seem to have very- very good efficiency with the GUI rendering (JBenchmark2). In reality, however, it doesn't even animate the components – just a static image is displayed; this is why it delivers extraordinarly good results in that test. Furthermore, all animations are far more jerky than with the intent MM; still, JBenchmark reports much better FPS values with J9 than with intent MM. That is, the J9-specific numerical results delivered by JBenchmark are completely useless.

You can also browse the screenshot images taken of these results in this folder. The image files all contain the model of the Pocket PC they were run on (for example, Wizard), the midlet manager used (J9, intent or CrEme), the number of the benchmark (d1: JBenchmark, d2: JBenchmark2 etc.) and, finally, the number of the screenshot of the same report (-1: first, -2: second etc.). That is, for example Wizard-CrEme-d1-2.png stands for the second (-2) screenshot of the intent MM test with JBenchmark (d1) made on the Wizard.

Incidentally, while JBenchmark delivers absolutely useless IBM J9 results, the JBenchmark online databases don't seem to contain (wildly) useless data. They contain a lot of, most probably IBM J9-based data (check out the non-Phone Edition benchmarks!) but they are significantly worse than those of intent. Therefore, the online JBenchmark database can be relied upon, comparison-wise, unlike the "offline" results JBenchmark produces with J9.

Opera Mini compliance

There're two versions of Opera Mini. The advanced MIDP2 version available here (this will work in any MIDP2-compliant midlet manager) and the "basic" MIDP1 version. With J9, you will need to use the latter because of the networking incompatibility; with intent, the former works great too. As CrEme doesn't let midlets access the network, it can't run Opera Mini either (not even the basic, MIDP1 version).

Yes, IBM J9 will only run the MIDP1 version. With the MIDP2 version, if it is able at all to access the Web, it, generally, won't be able to fetch the contents of long(er) pages entirely. (Tested with the latest currently available Opera Mini version, 1.2.3214.)

Note that, while the intent MM WM5 softkeys, in general, work, that won't be the case with Opera. Also note that you can use both the scrollbar and screen dragging for scrolling. Furthermore, the D-pad works too (Up/down: link jump; left/right: page jump). Finally, note that while J9 supports copying from / pasting to textfields, the intent MM doesn't allow for this. This may be the only real disadvantage of intent MM, compared to J9.

Installing midlets

With the intent MM and J9, you won't need to use .jad files (they're, along with .jar files, also offered for download by all Web pages offering midlet downloads); with CrEme, you must. With the former two, you need to deploy the midlets in them first and only after that can you execute them. With CrEme, you must hand-create a separate .lnk file pointing to your JAD files.

With both intent MM and J9, if the JAR/JAD files are associated with them, all you need to do is click a JAR file to be auto-imported. If they're not associated, you can provide both applications both a remote and a local URL to the JAR file.

Local midlets

With J9, you must use a file:/ / / URL. For example, if you have an a.jar file in the root directory, enter file: / / /a.jar in Install/URL as can be seen here.

With intent MM, go to Menu/Install/Local. Then, the application will display all JAR files on your storage card (but, interestingly, not in \My Documents, not even with a removed, non-existing storage card). Then, just click a JAR file to be deployed.

Remote midlets

With J9, use the same Install/URL; now, entering the full URL of the JAR; say, http://midlet.org/repository/spruce/spruceman/SpruceMan.jar?md=184, as can be seen here.

With the intent MM, go to Menu/Install/Browse and enter the URL (in this case, http://midlet.org/repository/spruce/spruceman/SpruceMan.jar?md=184) in the address bar of IE.

Associating

Of course, it's always the best to make sure JAD and JAR files are associated with your particular application. Upon installation, J9 associates them with itself and PPC PE devices already come with them associated with the intent MM. Should something mess up this, however, you can always restore the association by just importing the necessary registry files (please see this article for more information on registry editors and importing registry files). They are all available in this archive.

CrEme

As has been already pointed out, you must pass the JAD file (and not the JAR) to the CrEme runtime. These files must be located on your local PC, unlike with J9/intent MM (that is, you can't pass a URL to CrEme). Do this from a link file with the following contents:

255#"\Windows\Creme\bin\CrEme.exe" -Ob -classpath \ -mv jadfilename.jad

Modify -classpath \ to reflect the directory where your JAD and JAR file is located. Use single quotes (instead of double ones) if the path contains spaces. Also, modify "\Windows\Creme\bin\CrEme.exe" if you install CrEme to anywhere else than the non-main memory accordingly.

A step-by-step Tutorial on setting up Opera Mini

  1. if you have the intent MM, go to http://www.opera.com/products/mobile/operamini/phones/?phone=generic_advanced_midp_2 from inside Pocket Internet Explorer (PIE) / Internet Explorer Mobile (IEM; this is the new name for PIE begining with WM5) and click opera-mini-advanced.jar as can be seen here. On the screen that comes up, click Yes. The Opera midlet will be deployed inside intent MM; you will only need to click it, allow it to access the Net and also answer Yes to the EULA. This is done in exactly the same way as with the basic version (see the tutorial in the next, IBM J9-related section); the rendering of the dialogs will be a bit different though. After that, you can start browsing right away.
  2. if you don't have the intent MM, get and install J9 (if you don't want to download the entire 50 Mbyte installer, the CAB file can be downloaded from here; uncompress it, transfer to the PDA and click it there from any Pocket PC-based File Explorer).

Finally, don't forget to use Menu/Tools/History (advanced and basic screenshot) to quickly switch between the pages you've already visited during your browsing session – when you click a link or submit a HTML form (for people that know HTML/HTTP, even with POST), the old page will still remain accessible here and you can always return to it. This is one of the strengths of Opera Mini – much as it's a "simple" Web browser midlet, it still supports multiple windows.

A Tutorial on setting up Mobile GMaps

If you don't have the intent MM, get J9 and install it (see the Opera Mini tutorial on this). Then, go to http://www.mgmaps.com/download.php from inside Pocket Internet Explorer (PIE) / Internet Explorer Mobile (IEM; this is the new name for PIE begining with WM5) and click JAR as can be seen here. Your intent MM / J9 will ask you whether they can deploy it; just let them do it (J9 example here). Then, launch it.

The main menu dialog can be seen here (it's very similar when rendered in the intent MM). By clicking Start here, you can start it right away (after making sure "Yes" is chosen in the ubiquitous "Can Mobile GMaps use airtime" question). Then, you can use it right away as can be seen here and here (satellite view).

Note that you always need to install midlets the same way, regardless of their type/origin - you navigate to the given page using PIE/IEM, click the JAR link, let intent MM/J9 deploy the midlet and then, just launch it (and grant it Internet access rights if it's a networked and not just a local midlet).

For ADVANCED users: Where are deployed midlets stored? Additional advanced tips and tricks

After a hard reset, you don't need to re-deploy all your midlets one-by-one by hand in either intent MM or J9.

With the intent MM, the deployed midlets can be found in \Application Data\Tao\intent\; with J9, in \My Documents\midlets and \My Documents\recordStores.

With intent MM, you can simply copy the subdirectories of \Application Data\Tao\intent\app\jam\midlets\ to another device (or, redeploy on the same). The global midlet configuration data is stored in \Application Data\Tao\intent\app\jam\midlets\.midlets.db. This is a textual file that may be manually edited. This also means you can even add midlets to an already existing set of midlets by simply copying the midlet subdirectories to \Application Data\Tao\intent\app\jam\midlets\ and manually adding the additional records to .midlets.db. Note that, however, that you must do the latter using Unix End-of Line (EOL) characters – that is, simple 0A bytes should be used to denote the end of line, not the sequence 0D 0A. Therefore, if you use, for example, Wordpad (because it's able to edit files using the Unix EOL format, unlike Notepad) to edit the file, after editing it, you'll need to convert all 0D 0A byte sequences to single 0A's. I recommend the easy-to-use, free EOLNconv for this task.

With J9, you can also transfer/restore (but can't really add – unfortunately, some of the files in recordStores are binary) already-deployed midlets. Just make sure you transfer both \My Documents\recordStores and \My Documents\midlets.

Finally

Give a try to Opera Mini! I'm pretty sure you'll like it.

I also recommend Mobile Gmaps (direct JAR download here). It works flawlessly under both intent MM (screenshot 1 and 2) and IBM J9 (screenshot here)). Make sure you choose the MSN maps in Settings if you run into problems.

You can also give a try to the (generic) games over at midlet.org; they are, however, not very good – at least compared to mobile phone model/brand-specific, commercial games.

Recommended links

The Smartphone & Pocket PC Magazine Expert Blog. I always post the latest Java- and Web browser-related news, tips and tricks to the blog. Just use the blog search engine to find occurrences of Java .

Using Java on the Pocket PC - the complete tutorial. I keep posting (links of) all my new, Java-related articles to this thread too.

ADDITION (19:10 CET, the same day): I have been asked about NetFront (NF) 3.2, which also boasts a MIDP/CDC engine - in theory.

As upon downloading a JAD/JAR file, NF blindly saves them and doesn't try to actually deploy/execute them, I've scrutinized both the NF 3.2 demos (NF has no decent manual - the \Windows\nf3*.htm help files are far from perfect and don't contain a single word about the Java plug-in) in \JVLite2Demo and the system files in \Program Files\NetFront32\cdc.

As far as the former are concerned, there's only an applet demo (Calculator.lnk) and an application demo (HelloApp.lnk), nothing else.

As far as the system files are concerned, \Program Files\NetFront32\cdc\bin\cvm.exe, the main executable for the Netfront JVM, only supports the following command-line parameters:

-Xnologo
-Xlocale
-Xconsole
-XpauseOnExit
-Xappletmanager
-Xlogo

That is, as far as command-line params are concerned, it only has applications/applets and some generic, for example, console-related parameters – nothing midlet-related (as opposed to, say, the above-mentioned -mv flag in CrEme).

Finally, I've looked for the following essential midlet life cycle-related methods, exceptions etc. in both \NetFront32\cdc\bin\cvmi.dll and \NetFront32\cdc\lib\personal.jar:

MIDletStateChangeException
startApp
pauseApp
destroyApp

None of these words have been found – they are not implemented at all. (Of course, IBM J9, the intent MM and CrEme implements them all.)

That is, the Pocket PC version of NetFront 3.2 can not be used to run midlets. It only supports Personal Java/CDC, but not "real" midlets.

UPDATE (9:30 CET, the next day): added a full tutorial on setting up Opera Mini and Mobile GMaps.

UPDATE (9:30 CET, March 19, 2006): added information on MIDlet Manager.lnk

UPDATE (9:30 CET, June 6, 2006): the new IBM J9 has been released in the meantime. Please read THIS for more information.

Please read the new section I've just added. In a word: nope, it won't work.

You mean the one before the i-Jam or the new k-Jam? i-Jam (Magician) is the direct ancestor of k-Jam (Wizard). As far as i-Jam is concerned, it has no direct ancestor - it was the first PPC PE device with a 2.8" screen and has been parallelly released with the Blue Angel (XDA III). It's the latter that is the descendant of the XDA II.

In the meantime, some third-party, Java-less Google Maps clients have been released for the Windows Mobile. I'll elaborate them some time in a big roundup & tutorial. Stay tuned :)

"Also, i wish to know if there is any other way to open, read n write to a normal text file in a PDA, basically normal file handling operations using Java VM like J9 or CrEme 4.2?"

Yes, FileInput/OutputStreams and Writers/Readers work without problems.

Is the T-Zones a WAP-only, or a full GPRS Internet access? It's pretty cheap and, tehrefore, I think it may be WAP only.

If it's indeed WAP only, then, it's pretty unlikely you'll be able to as Opera Mini (as with all midlets) require a real GPRS subscription.

You may, however, want to check out the XDA-Developers forum; somebody may have invented a "hack" to circumvent this limitation.

Read THIS

Syndicate content