Windows Phone Thoughts - Daily News, Views, Rants and Raves

Check out the hottest Windows Mobile devices at our Expansys store!


Digital Home Thoughts

Loading feed...

Laptop Thoughts

Loading feed...

Android Thoughts

Loading feed...




Go Back   Thoughts Media Forums > WINDOWS PHONE THOUGHTS > Windows Phone Talk

Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2005, 12:06 PM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067
Default Using Java on the Pocket PC - the complete tutorial

Java is a hugely popular programming language with millions of programmers worldwide. It has a lot of advantages over traditional programming languages like C or C++ and some ever over C# (even when the latter has certainly eliminated some of Java's shortcomings and is definitely better for developing programs targeted at a specific platform like the Pocket PC).

Sun has made a major mistake when they stopped developing (please read this thread on this subject) its free PersonalJava implementation. Furthermore, Microsoft has never provided any JVM (Java Virtual Machine; the environment to run Java programs) for the Pocket PC platform either. This means we have to rely on third-party JVM's to run our Java programs on.

Fortunately, especially with some degree of hacking, these third-party JVM's are much more powerful and versatile than you would think.

What can I do with them? Are they more than just environments to run silly 'dancing letters' applets?

Yes, they are! In cases, they are very important to have. The most important example that comes into mind is the toonel.net client. Toonel.net is a free service to reduce Internet bandwidth usage. Please read my tutorial on setting it up on PPC devices.

There're other examples too. For example, I've released a few tools for the Pocket PC's to, for example, to create your own custom word dictionary, to extract embedded sound (WAV) files from Pocket Notes (PWI) files or to demonstrate the NetFront DST problem.

Also, as there is no decent compiler for the PPC platform. Forget the not-even-C-compliant PocketC, which requires the programmer to learn a completely new, WindowCE-specific - you can't use the experience you've gained anywhere else, unlike with Java or C#! - language & class library. It's just a toy if you compare it to the C# and the CF combo or Java, especially if you take into account the need for learning a new library and being developed by a small developer firm compared to Microsoft or Sun.

There may be a lot of situations you need to do some specific task on your PDA (for example, writing/modifying a rudimentay HTTP proxy that deletes/modifies some HTTP headers or kills some ad HTTP requests to save bandwidth - this kind of coding can be finished by an experienced Java programmer in a few minutes and you really don't need a desktop computer for this) you can't do in popular scripting languages like MortRunner and you don't want to use any desktop computer emulator (for example, PocketDOS) on your PDA to write a non-native solution to do the stuff either.

With Java, even program development and compiling are certainly possible.

What JVM's are available now?

Not many, but, fortunately, more than for the Palm OS, also with great hackability and real J2SE-compliance (unlike with plain CLDC/MIDP solutions).

Insignia/Esmertec Jeode:

this JVM is not sold any more except for the overly expensive Jbed version. Because this JVM was freely shipped with a lot of iPAQ devices and can be installed on any kind of PDA's, you may still want to use it. I certainly recommend it if you still have it lying around on some of your old iPAQ CD's.

I really recommend this JVM if you still have it. It works great in almost all situations (with toonel, my tools or as a compiler) and has a very good 'hackability' factor.

Installing it is pretty starightforward. If you install an old(er), but still perfectly usable version like 1.7.3, you may need to relocate it into a storage card because this version will only install to the main memory. You can relocate it to any card if you, after installing it, go to the \Windows directory and move Jeode.evm, evmawt.dll, evmcore.dll, evmpie.dll, iepluginvm.exe, hwawt.dll, javalib.dll, jdwp.dll, math.dll, net.dll and evm.exe from there to the new destination on yoru card. Make sure you also move the \Windows\lib subdirectory in there, so that the files that were in \Windows\lib are in a subdirectory called \lib in the new directory, just under the above-listed files. (I've also described this relocation here.)

As with all the two other major JVM versions (J9 and CrEme), it has no registry entries so you can freely relocate it and/or just copy it from one device to another. This also means that you can have several versions of Jeode (or, for that matter, J9 and CrEme) on the same device - they won't interfere in each other. This is definitely a big plus, especially if you compare the capabilities of different versions of the same JVM and you don't want to do this on two different PDA's.

IBM J9, Personal Profile 1.0:

(please do not mistake it for the IBM J9, MIDP 2.0 version. The latter can't be used for running standalone applications. It only has Midlet support. To find out more about using it for running Midlets, please read this thread.)

This is a very cheap (US$ 6) JVM, which also has a trial version. Excellent for running Java applications, even toonel. Its hackability factor is, however, much less than that of CrEme or Jeode. It can't function as a compiler either. For running already-made programs that only use Java 1.1, however, it's great. It's easily relocatable and also survives even a hard reset if installed on a memory card, just like with the other major JVM's.

CrEme:

a very fast (especially at compiling other programs, compared to Jeode) JVM. It renders AWT widgets/text different from Jeode/J9 though, which may be a showstopper in cases like running it on a VGA device.

It currently has two versions: the PersonalJava (that is, JDK1.1.8) -compliant 3.x (3.26 is the latest) and the CDC1.1/MIDP1.0-compliant 4.x (currently in beta stage; 4.0b8 is he latest build). Which of the two? Most apps (including the compiler) will run using the stable 3.x versions. Furthermore, I've been unable to made toonel work with the current 4.0 beta version. Therefore, you needn't to run to pick the latest beta instead of a stable build.

Can be used for compiling programs and has a good 'hackability' factor.

A little bit of warning: if you execute the installer app on a desktop Windows that has a localized \Program Files directory (for example, the German Windows, which has \Programme instead), the installer will fail (this bug has been noticed also by me). This is a bug still present in the latest, 3.26/4.0b8 versions. You MUST run the installer app on a Windows version that uses the standad \Program Files directory name.

NetFront JVM:

this JVM comes with the Java-enabled NetFront Web browser. As of version 3.1 (I haven't tested the JVM shipped with version 3.2 yet, but, hopefully, will manage to do it in a few days), this JVM can be used to run some standalone programs (but definitely not all of them - it didn't run, for example, my ).

Its 'hackability' factor is pretty low (again, see my posts on compilation at Pocket PC Thoughts); it can't really be hacked to run my NetFront DST problem demo.

Installing

The three stand-alone JVM's are very easy to install. J9 and CrEme can be installed straight to a memory card; older versions of Jeode must be relocated to there manually (it, again, isn't complicated at all). The JVM in NetFront gets installed with the NetFront browser - you don't need to install it by hand. (And, incidentally, you don't need to enable it inside NetFront either.)

After installing the given application, it's ready to run anything.

Running applications in Pocket PC JVM's

Applications mostly come in JAR files. (For the Java-savy: you can also run individual class files in the four JVM's too. I've described this in my compilation-related article. This is best used if you also compile your Java programs on your PDA and . However, because most Java programs are distributed in a JAR file, to keep things simple, I only explain how JAR's should be run.)

You'll need to put the absolute path (for example, \jars\someApp.jar) of these JAR files in the so-called 'classpath' variable, which you pass to the JVM executable file described in the next paragraph.

Just like with any Pocket PC program, JVM's also have an EXE file to run. You must supply the JAR file path and the class that must be run to this program. The four JVM's need to be invoked the following way from the standard WindowsCE .lnk (link) files:

Jeode:
255#"\<path to home directory>\evm.exe" -Djeode.evm.console.local.keep=true -cp <full JAR file path> <main class name>

CrEme:
255#"\<path to home directory>\bin\CrEme.exe" -Ob -classpath <full JAR file path> <main class name>

IBM J9:
255#"\<path to home directory>\bin\J9.exe" "-jcl:ppro10" -cp <full JAR file path> <main class name>

NetFront:
"255#"\<path to home directory>\jvlite.exe" -classpath <full JAR file path> <main class name>

You can create these link files by hand if not supplied. They only should contain one row - the one that has just been shown. You can put these .lnk files anywhere in your \Windows\Start Menu\Programs directory - they will behave like a "real" link file, just like the ones Windows CE is shipped with.

The <path to home directory> is, for example, \Program Files\NetFront3\ with NetFront 3.1 installed into main memory, \Windows with Jeode installed into main memory, \<card name>\IBM PPRO10\ with IBM J9 installed into a storage card etc. You can easily find it with Pocket File Explorer or, even better, from the desktop using Total Commander with the WinCE file system plug-in.

That is, if you decide to store your something.jar file in, say, \SD Card\something.jar, you'll need to pass "\SD Card\something.jar" (notice the " marks! They are needed if the path contains a space like in "SD Card"!) as the <full JAR file path> parameter.

The second parameter passed to the JVM exe file is the name of the main class. With my programs, it's exactly the same as the JAR name. With, for example, toonel, it's gui.ClientForm. (For the Java-savy, you can't use the well-known <JVM exe name> -jar jarfilename execution form with any of the JVM's). If you are unsure/don't know this, rename the JAR file to a ZIP file and go into it with, say, Total Commander, Go to the META-INF subdirectory and read the MANIFEST.MF file in there. It'll contain something like this:

Manifest-Version: 1.0
Main-Class: gui.ClientForm


You'll need to pass the JVM EXE file the value that stands after the Main-Class attribute; that is, gui.ClientForm in this case.

Please note that you will need to switch to the console mode with command-line batch variable support if you want to invoke your Java applications with varying parameters. You can pass parameters to your applications in your link files (the parameter(s) come(s) just after the main class name), but if you need to run your application on several different files to be processed (see for example my embedded-sound-PWI or user.dic-to-WinCE-wordlist converter), you may be better bite the bullet and install/get familiar with a console environment like PPC Command Shell, also described in my Java compiling-on-the-PDA article.

The most important links on other tutorials/forums:

Java on PocketPC, the Unofficial FAQ - perhaps the best and most up-to-date article/FAQ on PPC JVM's

The focal point of Pocket PC & Java-related discussion

Some other links (not as recommended as the two above!):

Java Support on Pocket PC - a heavily outdated article; it contains a lot of links to non-exisiting JVM's.
Java On Pocket PC Devices, Mikko Kontio - only discusses a small subset of running full-fledged Java apps on the PPC; still, may be worth reading for some
JAVA for PocketPC PDA's - one of the most detailed articles (next to the Unofficial FAQ linked as first) on recent JVM's.
 
Reply With Quote
  #2  
Old 08-15-2005, 09:56 AM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067

While evaluating Pocket Mechanic in the Utilities /Maintenance category (I will publish a detailed roundup of these apps in the near future, so, stay tuned ) during the Pocket PC magazine Best Software Awards 2005 process, Iíve noticed another bug in CrEme, in addition to the System Path bug, also discovered by me: it registers .jar and .jad files in the Registry without using ď marks when entering the path of creme.exe to the Registry. This will mean the system wonít find creme.exe at all when you click a .jar or a .jad file.

Curing this problem is very simple: insert " marks before and after the \< home>\NSIcom CrEme\bin\creme.exe string (so that the entire registry value becomes "\\SD-MMCard\\NSIcom CrEme\\bin\\creme.exe" -Of -mv '%1') in both [HKEY_CLASSES_ROOT\jadfile\Shell\Open\Command] and [HKEY_CLASSES_ROOT\jarfile\Shell\Open\Command] .
 
Reply With Quote
  #3  
Old 08-15-2005, 05:16 PM
burtcom
Intellectual
burtcom's Avatar
Join Date: May 2006
Posts: 237
Default How does one purchase crEMe?

The nsicom site has an option for downloading the trial version of CrEme, but there isn't any mention of how to buy or how much it is. Can any of you CrEmeusers enlighten us?
 
Reply With Quote
  #4  
Old 08-16-2005, 07:03 AM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067
Default Re: How does one purchase crEMe?

Quote:
Originally Posted by burtcom
The nsicom site has an option for downloading the trial version of CrEme, but there isn't any mention of how to buy or how much it is. Can any of you CrEmeusers enlighten us?
I couldn't find any price either. You could send an e-mail to the NSICom people, as is recommended for example .here
 
Reply With Quote
  #5  
Old 08-16-2005, 03:13 PM
burtcom
Intellectual
burtcom's Avatar
Join Date: May 2006
Posts: 237

Already e-mailed

Still waiting to hear back.

I'm a little worried -- since they don't publish the price on the site -- that it's uber-expensive (i.e. if you have to ask, you can't afford it)

I'll report here when/if I hear back.
 
Reply With Quote
  #6  
Old 08-18-2005, 03:18 PM
burtcom
Intellectual
burtcom's Avatar
Join Date: May 2006
Posts: 237

Sorry to have to tell you folks, but for most of us CrEme is not a (legal) option.

There is no single-user license available -- the minimum number you can get is 1000.

And, as noted in the License Agreement below, you are allowed to use it for only 30 days for evaluation putposes.

Too bad -- perhaps if enough people bug them they'll consider a single license for personal use, like IBM does for their product.

------------------------------------------------------------------------------

CrEme(tm) Evaluation License Agreement

Please read the terms and conditions of this agreement carefully before using CrEme or it's associated programs and documentation.

This agreement represents the entire understanding between you and NSIcom Ltd. ("NSIcom"), concerning CrEme, and supersedes any prior
agreements.

BY USING THIS SOFTWARE YOU ARE AGREEING TO BECOME BOUND BY THE TERMS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO THE TERMS OF THIS AGREEMENT, DO
NOT INSTALL THE PROGRAM.

LICENSE GRANT:
NSIcom, Ltd. ("NSIcom") grants you, and you accept on the first use, a personal, non-transferable and non-exclusive right to use the CrEme(tm) ("SOFTWARE") contained herein on a single processing unit for evaluation purposes only and for a period of 30 days from the date of the first use of the SOFTWARE. This license shall apply only to the SOFTWARE referenced above, and shall not apply to any other software products and shall not convey any rights in other NSIcom software except as provided herein.
You may not copy or distribute CrEme in any way and for any purpose without the explicit prior written consent of NSIcom. You must purchase a full-use license if you wish to do any of the following: (a) use the SOFTWARE after the end of the 30-day trial period, or (b) use the SOFTWARE for any development, commercial, or production purpose, or (c) distribute the SOFTWARE for any such use.
 
Reply With Quote
  #7  
Old 08-30-2005, 05:00 PM
martin_ayton
Thinker
martin_ayton's Avatar
Join Date: Aug 2006
Posts: 459

I'm just downloading the IBM JVM from Handango. 89.4MB - ouch! I'm not sure I want to take up that much space on my SD card. How much space does this actually take up when it's loaded?
 
Reply With Quote
  #8  
Old 08-30-2005, 05:11 PM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067

Quote:
Originally Posted by martin_ayton
I'm just downloading the IBM JVM from Handango. 89.4MB - ouch! I'm not sure I want to take up that much space on my SD card. How much space does this actually take up when it's loaded?
The PP JVM takes some 5M, the MIDP JVM takes some 2M.
 
Reply With Quote
  #9  
Old 09-06-2005, 12:53 PM
Fergus
Pupil
Join Date: May 2004
Posts: 36

I'm interested in developing a small application along the lines of a flash card/quiz program for the PPC platform. Is developing this or any PPC application viable using Java. If i were to make this publicly available would this cause any problems or is the C# (net?) route a better alternative in this case.

I haven't programmed in C for years and have just started learning Java which i would like to continue with. What do you think taking into consideration i have not developed for PPC before.

Many thanks
Fergus
 
Reply With Quote
  #10  
Old 09-06-2005, 12:59 PM
Menneisyys
5000+ Posts? I Should OWN This Site!
Join Date: Jun 2007
Posts: 5,067

Quote:
Originally Posted by Fergus
I'm interested in developing a small application along the lines of a flash card/quiz program for the PPC platform. Is developing this or any PPC application viable using Java. If i were to make this publicly available would this cause any problems or is the C# (net?) route a better alternative in this case.

I haven't programmed in C for years and have just started learning Java which i would like to continue with. What do you think taking into consideration i have not developed for PPC before.

Many thanks
Fergus
I'd definitely choose C# over Java for purely PPC-related development. C# (CF) is natively suppoted by the operating system, unlike Java. That is, your app will run on any PPC if you write it in C#/CF.

Furthermore, C# is an extended, even more logical/clever version of Java. You'll certainly like it.
 
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:06 PM.