I’ve started using the J2ME Polish library in a JavaME project since using the default lcdui interface library isn’t a realistic choice for anything but the most sparse utility applications. J2ME Polish is more than a replacement UI library: it’s a build process which allows the developer a smooth upgrade path from their existing lcdui based code, beginning with the insertion of style directives which J2ME Polishes build process turns into additional java code just before javac get’s busy. The ability to make these directives conditional, and based on separate style sheets also eases deployment across different devices. Its a clever scheme, using Ant, but this does come at a cost; it is very fussy about its running environment and, unless you are already very experienced with Ant, some aspects of it can be bewildering. It’s clearly not plug-in-and-go software, so developers have a fairly steep learning curve before its power is unleashed. I’m going through my own trial-by-fire with it now; so here are some handy notes for anyone up against the same issues (including myself, later, when I forget
):
Adding JAR Libraries: If your project references another JAR (one that isn’t part of the MIDP, CLDC or the J2MEPolish library) you’ll quickly discover that adding it to the project build path in Netbeans or Eclipse, in the normal way, is ignored by the J2ME Polish build process! Since the Ant build script controls the build process, it’s natural to look here next for an obvious ‘classpath’ entry, but theres no joy to be had here either. After much Googling, I found the answer is to add an attribute called binaryLibrary to the <build> element of the Ant script, in build.xml, like so:
<build
symbols=”ExampleSymbol, AnotherExample”
fullscreen=”menu”
usePolishGui=”true”
binaryLibrary=”/home/user/NetBeansProjects/exampleProject/kxml2-min-2.3.0.jar”
workDir=”${dir.work}”
>