So I decided to learn Java ME development. And I came across a blog called - well what do you know - the Java ME Blog, over at  Using the info on this blog along with what I found on the awesome (, I was able to write a small MIDlet, and build it. Ah, now to run it... Not so fast; I kept getting an error message along these lines:

Starting emulator in execution mode No such file or directory
   at java.lang.PosixProcess.<init>(
   at java.lang.Runtime.execInternal(
   at java.lang.Runtime.exec(
   at java.lang.Runtime.exec(
   at Source)
   at com.sun.kvem.environment.EmulatorInvoker.runEmulatorOtherVM(Unknown Source)
   at com.sun.kvem.environment.EmulatorInvoker.runEmulator(Unknown Source)
   at com.sun.kvem.environment.ProfileEnvironment$KVMThread.runEmulator(Unknown Source)
   at com.sun.kvem.environment.ProfileEnvironment$ Source)
Caused by: No such file or directory
   at java.lang.PosixProcess.nativeSpawn(
   at java.lang.PosixProcess.spawn(
   at java.lang.PosixProcess$

After about 2 hrs of head-scratching and forum-and-mailing-list-hopping, I found two methods to solve the problem. They are explained below:

Method 1 - the hard way

Configuring default JDK on your Kubuntu Hardy box

To make Kubuntu recognize your jdk (JVM), use the update-alternatives command and issue following 3 commands one after another:
sudo update-alternatives --install /usr/bin/java java <JDK_INSTALL_PATH_HERE>/bin/java 100
sudo update-alternatives --install /usr/bin/jar jar <JDK_INSTALL_PATH_HERE>/bin/jar 100
sudo update-alternatives --install /usr/bin/javac javac <JDK_INSTALL_PATH_HERE>/bin/javac 100

These 3 commands set your java, jar and javac commands. You can use same to set other java executables if you want.

Now running sudo update-alternatives --config java will give you a choice between the JDKs available on your machine and you can (if it doesn't already have a * next to it)
set the Sun JDK as your default. Running java -version should give you an output similar to this:

java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

HOORAY!! You're good to go. Running your application will now go smoothly.

Method 2 - The easy way

This method is cool because you don't have to change your system settings.
1. Open the file <NETBEANS_INSTALL_DIRECTORY>/mobility<WTK_VERSION>/bin/emulator in your favourite text editor ( ala nano, kate, vi, etc)
2. About the 3rd line you will find a line similar to
    Change that line to

And you're done! Did you expect more? Sorry. Nothing to see here... Move right along and run your app. Now you will see a cool emulator phone on your screen.

Well that's all for now folks. More tips coming soon.

Signing out - Tash.