Version: 2.0

Posted: 2007-06-01

Build Requirements: J2SE 1.4 or later, Ant 1.7.0 or later. Xcode project requires Xcode 3.0

Runtime Requirements: J2SE 1.4 or later

View Source Code:

Download Sample (“”, 74.9K)
Download Sample (“OSXAdapter.dmg”, 126.3K)


This sample uses a reflection Proxy model to hook existing preferences, about, and quit functionality into handlers for the Mac OS X application menu. This functionality is easily adopted by implementing the interface, but this sample's dynamic implementation will only be triggered on platforms that actually support the Apple APIs (e.g. Java 1.4 or later on Mac OS X), avoiding any compatibility concerns.

This sample is for developers looking to support multiple platforms, including support for Mac OS X-specific features, with a single codebase. It is written for and should build and run on any J2SE 1.4 implementation without any stub or placeholder libraries.

Document Revision History

Date Notes
2007-06-01Rewritten for compile-time as well as run-time portability. Requires Ant 1.7 or Xcode 3.0.
2006-10-17Minor code cleanup; no new features.
2006-07-07Removed some extraneous import statements.
2006-04-12Updated compiler options to generate 1.4 compatible bytecode.
2005-02-08Replaced call to Class.forName with ClassLoader.getSystemClassLoader().loadClass
2004-06-03Updated to new disclaimer, brought platform check inline with TN2110
2003-04-30Hooks into the Mac OS X Application Menu with the classes via reflection.

Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.