Access restriction: The type 'Application' is not API (restriction on required library rt.jar)
Solution 1:
This happened to me as well, and the answers given here already were not satisfying, so I did my own research.
Background: Eclipse access restrictions
Eclipse has a mechanism called access restrictions to prevent you from accidentally using classes which Eclipse thinks are not part of the public API. Usually, Eclipse is right about that, in both senses: We usually do not want to use something which is not part of the public API. And Eclipse is usually right about what is and what isn't part of the public API.
Problem
Now, there can be situations, where you want to use public Non-API, like sun.misc
(you shouldn't, unless you know what you're doing). And there can be situations, where Eclipse is not really right (that's what happened to me, I just wanted to use javax.smartcardio
). In that case, we get this error in Eclipse.
Solution
The solution is to change the access restrictions.
- Go to the properties of your Java project,
- i.e. by selecting "Properties" from the context menu of the project in the "Package Explorer".
- Go to "Java Build Path", tab "Libraries".
- Expand the library entry
- select
- "Access rules",
- "Edit..." and
- "Add..." a "Resolution: Accessible" with a corresponding rule pattern.
For me that was "
javax/smartcardio/**
", for you it might instead be "com/apple/eawt/**
".
Solution 2:
I was having the same problem. When I initially created the java project in Eclipse I specified JRE 8. When I went into the project's build path and edited the JRE System Library, the Java 8 execution environment was selected. When I chose to use an "Alernate JRE" (still java 8) it fixed the error for me.