Thursday, August 21, 2008

Write once run everywhere, eh??

Writing a desktop application in Java means dreaming of an application that we wish will run on any platform. One "fatal" mistake that I saw today, i.e. assuming that the file separator is "\", guess on which platform the application was developed.

To avoid this kind of mistake, simply use File.pathSeparator instead of hardcoding "\" in the code.

Thread, if we playing around with thread, make sure that your threads won't cause any deadlock, if it run in windows, don't you ever believe 100% that it will run in *nix. Each os has different way of scheduling threads, so beware.

Drawing on canvas, handling mouse events, creating custom component, if your code does this, test it on all platforms before you claim that it runs everywhere (at least windows, linux, mac).

It seems the dream of having an application which runs anywhere is not yet fully realized. But still I'm grateful for what Java provides now and will look for the realization of the dream.

No comments: