Archive for November, 2008

Java Runtime and cmd.exe unicode issue

Thursday, November 13th, 2008

For many years our product used the following code to open URLs or files on Windows 2000 and XP.

final String[] cmds = { "cmd.exe", "/C", "start", "/B ", "/WAIT", url };

This code is really simply and works well. If you have different editors configured for a specific file type the start launches the correct viewer/editor. It also opens the users preferred web browser too.

We didn’t have many issues with this until we started added more localisations to our product and supporting unicode fully.

This code in theory looks good, but it didn’t work in many cases. I found that the cmd.exe process on a European Windows system runs in ISO-8859-1 so any arguments we passed it get completely messed up.

This means the cmd.exe cannot be used as it doesn’t support unicode.

I spent days looking for another alternative but couldnt find a java only fix.  In the end we had to use JNI and use the Windows ShellExecuteExW and ShellExecuteEx calls (based on whether we used a unicode or none unicode string)

Using ISO files in Linux and Windows.

Thursday, November 13th, 2008

I’ve started to use more and more ISO images as disk space is becoming cheaper and its a lot easier to manage ISO files compared to physical CDs/DVDs.  Mainly because I keep forgetting where I put the physical media.


Create an ISO file using dd

 dd if=/dev/cdrom of=image.iso

Mount the ISO using local loop back download smokey and the bandit part 3 movie (you may need to be root)

mkdir /mnt/disk
mount -o loop image.iso /mnt/disk


For Windows you should get a copy of the free program MagicDisk

I use it all the time at work and I’ve never had any problems with it.   Its small simply and works well.