1

I'm developing an Eclipse Plug-in where I use Nashorn. When I run the same application as a standalone Java application, I face no errors. But when I run it as a plugin, I get this error -

java.lang.NoClassDefFoundError: jdk/nashorn/internal/runtime/options/Options

The stack trace further points to a location where I'm creating an Options object. I've already tried adding access restriction rules(just in case), but it doesn't help. I've also seen these two related links - How to make jdk.nashorn.api.scripting.JSObject visible in plugin , Access restriction: The type 'Application' is not API (restriction on required library rt.jar) , but the problem persists. I have double checked to ensure that the project is using Java 8.

Help?

Community
  • 1
  • 1
Kazekage Gaara
  • 14,972
  • 14
  • 61
  • 108
  • 1
    Why do you use `Options` in the first place? Its authors have marked it 'internal', not to be used by clients, it may vanish at any time, it ties your application to the Oracke JDK and finally requires class loader hacks in OSGi. – Rüdiger Herrmann Feb 22 '16 at 07:30
  • @RüdigerHerrmann because I want to be able to do something like `options.set("anon.functions", true);options.set("parse.only", true);options.set("scripting", true);` – Kazekage Gaara Feb 23 '16 at 23:32
  • 1
    I can understand the desire/need to configure these options but still, you tie the application to the current version of the Oracle JDK, Future versions might simply break your application. However, you can let the OSGi system bundle export the restricted packages as described here http://stackoverflow.com/questions/1513083/depending-on-com-sun-javadoc-from-tools-jar-sun-jdk-in-eclipse – Rüdiger Herrmann Feb 24 '16 at 07:45

1 Answers1

0

I have got it working, but this seems more like a hack than an actual solution. I've copied nashorn.jar from jdk1.8.0_66\jre\lib\ext and included it in my build path.

Kazekage Gaara
  • 14,972
  • 14
  • 61
  • 108