11

When I do multi-platform testing on Windows it gets annoying that Eclipse shows errors in the project because of the com.apple.eawt code that I have in a special Mac customization task. Worse yet, if I export a runnable jar on Windows, it won't run on mac because of the unresolved compilation problems.

What's the best way to let Windows Java and com.apple.eawt live in peace? I can't see how I would be able to spin off the code to a jar, since it requires access to lots of the program's state.

Kara
  • 6,115
  • 16
  • 50
  • 57
Yuvi Masory
  • 2,644
  • 2
  • 27
  • 36

4 Answers4

13

I created an updated jar to solve this problem. GitHub source here. It's hosted on maven central

Yuvi Masory
  • 2,644
  • 2
  • 27
  • 36
6

This looks like it could be what you're after: http://developer.apple.com/mac/library/samplecode/AppleJavaExtensions/

This is a pluggable jar of stub classes representing the new Apple eAWT and eIO APIs for Java 1.4 on Mac OS X. The purpose of these stubs is to allow for compilation of eAWT- or eIO-referencing code on platforms other than Mac OS X.

Tuna
  • 2,937
  • 4
  • 37
  • 61
matt
  • 78,533
  • 8
  • 163
  • 197
  • 1
    Oh man what a bummer. Since it's for an old JDK it doesn't support setDockIcon() which I need for when the app is launched through Java Web Start. But thank you for the lead!! – Yuvi Masory Jan 28 '10 at 00:01
0

Put the OS X specific code in a separate class.

In your main code, use reflection to see if one of the Apple classes are present (or a Class.forName), and if so, THEN invoke the separate class above. I cannot remember if you can do that safely just by calling it, or you need to invoke the separate class by reflection too.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
0

The latest can be downloaded from http://developer.apple.com/library/mac/samplecode/AppleJavaExtensions, click on the "Download Sample" button at the top of the page

The latest documentation is at

http://developer.apple.com/library/mac/documentation/Java/Reference/JavaSE6_AppleExtensionsRef/api/index.html?com/apple/eawt/Application.html

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • As of March 2014, the documentation link gives a Page Not Found. Gotta love Apple's habit of moving stuff around. *sigh* – KathyA. Mar 31 '14 at 17:42