Many examples, including Oracle's own tutorial refers to some classes in the package jdk.hashorn.api.scripting
. However it is not part of the standard Java 8 release. And when I tried to add it to my code, it tells me: Access restriction: The type 'NashornScriptEngineFactory' is not API (restriction on required library 'C:\Program Files\Java\jre1.8.0_25\lib\ext\nashorn.jar')
.
How can I use the ClassFilter feature in my java project?
Use the current release 1.8.0_40
, not 1.8.0_25
. From the release notes:
New Java class-access Filtering Interface
The jdk.nashorn.api.scripting.ClassFilter interface enables you to restrict access to specified Java classes from scripts run by a Nashorn script engine. See Restricting Script Access to Specified Java Classes in the Nashorn User's Guide and 8043717 (not public) for more information.