1

I'm trying to do a few imports from com.apple.eawt (using Eclipse) like this:

import com.apple.eawt.AboutHandler;
import com.apple.eawt.AppEvent;

But I get "the import com.apple cannot be resolved" for each statement. I've looked at other similar questions, and it seems people are saying it is a build path error. I tried the suggestion in one of the questions to add an accessibility rule like this:

com.apple accessibility rule

But I still get the error even after restarting Eclipse. The other thing is that all of the questions I've seen are using MacOS, so I don't know if that makes a difference.

Community
  • 1
  • 1
dumbitdownjr
  • 185
  • 3
  • 12
  • Do you see the com.apple.eawt or something similar in your dependecies (build path)? – vinkomlacic Jul 02 '19 at 22:45
  • I don't see anything similar in the classpath, but the system library is in the modulepath. I think it should be in the module path since the classpath only has jar files so far. – dumbitdownjr Jul 02 '19 at 23:09
  • Are you using Mac? Because https://stackoverflow.com/questions/13978471/com-apple-eawt-what-exactly-i-should-install says the JAR comes out of the box on the Mac JDK. Not sure how to handle the problem for other OS-s – vinkomlacic Jul 02 '19 at 23:13
  • I'm using Windows, so yeah its kind of weird because all of the other questions relate to Mac, so I'm not sure if it is different on Windows. Maybe the problem is that I'm using jdk 9? – dumbitdownjr Jul 02 '19 at 23:23
  • Yeah, that could be it too. They have removed some of the packages so you have to install them separately in Java 9 – vinkomlacic Jul 02 '19 at 23:24
  • I haven't found anywhere to install them from, or else I would do that. This project is an older version of Jabref, and I was looking through the commit history and it seems like they removed these imports. The only reference they have to com.apple is in a file called external_library.txt, but I'm not sure how that is being used. – dumbitdownjr Jul 03 '19 at 00:10

1 Answers1

3

The com.apple.eawt package is a MacOS-specific package intended to permit java applications to work like native MacOS applications. You would only find this package in a JRE/JDK for the MacOS platform. You say you're building on Windows, which wouldn't have this package.

On top of that, beginning with Java 9 the com.apple.eawt and other Apple-specific packages are encapsulated and no longer accessible without taking special steps. Even if you were building on MacOS, you'd have to override the encapsulation to access the package.

JEP 272 describes a public API which is intended to be a cross-platform replacement for com.apple.eawt. If you're motivated, you may be able to port your program to the new API.

Further reading:

Kenster
  • 23,465
  • 21
  • 80
  • 106