Testing Cross-Platform Compatibility

The most reliable way to ensure that your application runs on another platform is to test it out—run your code on as many platforms as possible before releasing it or considering the development complete. Testing compatibility will reveal some of your most obvious problems, such as GUI elements that don’t display correctly. That said, some specific areas of your application should be tested rigorously.

File I/O

Make sure your application can read and write files correctly. If the platform supports path or file names with spaces (such as on Mac OS X), see if your application handles this task correctly. Also, find out how the application handles high-bit characters (for example, ™, ä, ê, and ó).

Preference and Resource Files

You’d be surprised how often you’ll see a hardcoded reference to a path in a Java application. Try opening the preferences dialog, changing and saving preferences, and quitting and reopening the application. If you use JDK 1.4’s Preferences API, be aware that preferences are not guaranteed to migrate across platforms (or even different systems running the same platform). If migration is a requirement, you might want to consider a different preferences mechanism. If you’re using ordinary Java property files, remember that they are saved to disk as 7-bit text files, and users who try to edit them manually might encounter difficulties with high-bit characters.

Instead, rely on JAR files to contain resources and values returned ...

Get Mac OS X for Java Geeks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.