Java Swing Mac FAQ: How to determine if you're running on Mac OS X

Java Mac FAQ: How can I determine whether my Java/Swing application is running on Mac OS X, or some other operating system?

Here's the test I use to determine whether my Java application is running on Mac OS X:

boolean isMacOS = System.getProperty("mrj.version") != null;

I can't find the reference to it at the moment, but I'm 95% sure I found this test on Apple's web site, because I found this code in a Swing application that has been heavily modified to look and feel like a native Mac application, and I know I was crawling all over Apple's website at that time.

 

Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.