up previous next contents
Up: java-on-mac Previous: Running the native system Next: Putting the JMenuBar on   Contents

Identifying that you're running on Mac OS X

Assuming that you're developing your application to run on multiple platforms, the next thing you need to know is if your Java/Swing application is running on a Mac OS X system. According to this Apple resource page this is the proper way to determine if you're application is running on a Mac:

String lcOSName = System.getProperty("os.name").toLowerCase();
boolean IS_MAC = lcOSName.startsWith("mac os x");

Just run that code somewhere early in the startup cycle, then use that boolean field later to know whether you need to run the Mac-specific code shown in this tutorial.

As you can see from that page, you can also identify the JVM version, if need be.