Re: Class Loading on Different Opperating Systems



In article <1143817777.413406.86060@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"Rationem" <rationem@xxxxxxxxx> wrote:

In an attempt to handle the special CMD+Q on a Mac that resides in the
application menu I had to put in the following code:

if (System.getProperty("os.name").toLowerCase().indexOf("mac")
!= -1)
{
com.apple.eawt.Application app = new
com.apple.eawt.Application();

app.addApplicationListener(new
com.apple.eawt.ApplicationAdapter() {
public void handleQuit(com.apple.eawt.ApplicationEvent
e)
{
attemptToQuit();
}
});
}

This works properly on a Mac but does not work on a windows machine
because the com.apple.eawt.* classes are not avabilible. Is there any
way I can use this code and still maintain the cross-platform aspect of
java?

Thanks,
Adam

I can't imagine why you're using toLowerCase, since the value of that
property when running on Mac OS X will be *exactly* "Mac OS X" on every
system.

In what way is it failing on Windows? Do you have code references
elsewhere (not shown here) to those Apple classes that are evaluated at
runtime on a Windows machine?

You might find more help from Apple via some useful web pages at
<http://developer.apple.com/referencelibrary/Java/idxPorting-date.html>.
On that page is a link entitled OSXAdapter that shows (with source code)
how to use reflection to hook these Apple classes into an application.
Just below it is one entitled Unsolicited About Boxes which shows more
on how to properly override the About and Quit behaviors. And just
below that is a link entitled AppleJavaExtensions where you can get stub
classes for compiling on other platforms. I would think that one or
more of those would provide useful answers.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
.