Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java-Mac OS X integration without breaking platform independence

I want my application to integrate Mac OS X better. I've read Mac OS X Integration for Java and I've learned I have to import com.apple.eawt.* and write some extra code. But, if I do this, my application is not going to work on Windows because of missing reference. I could do this with preprocessor command if I write in C but this is Java. How can I do this without separating the code file into 2 branches?

like image 597
Cenk Alti Avatar asked Jan 10 '10 20:01

Cenk Alti


People also ask

Can Java run on Macintosh platform?

On the other hand, every version of Mac OS X is a system ready to run your Java application. Included in Apple's operating system is both the JRE and JDK for J2SE v1. 3.1.

Why does my Mac say unable to locate a Java Runtime?

The message “Unable to load Java Runtime Environment” means that the Mac computer cannot load JRE, either because it is out of date or (more usually) because it has not yet been downloaded and installed. It can also happen after the computer OS X has been updated, e.g. to 10.14 Mojave from 10.13 Maverick.


2 Answers

Macify it.

like image 101
Jay Askren Avatar answered Nov 12 '22 13:11

Jay Askren


I used reflection to see if the com.apple.whatever class was there, and if so, I invoked it.

Worked very well, and does not create breaking imports.

like image 39
Thorbjørn Ravn Andersen Avatar answered Nov 12 '22 11:11

Thorbjørn Ravn Andersen