Search code examples
javafxjavafx-8nashorn

Using JavaFX in Nashorn with embbeded scripting (no -fx)


I have a Java 8 application that runs JavaScripts. I see that I can run JavaFX applications by running jjs -fx. However, my environment is a pure Java 8 JSE app and is launched as a standard Java app.

Is it possible to use JavaFX in scripts that are started with a Nashorn eval()?

So far, all the examples and study I have found seem to show JavaFX being run from jjs as opposed to being embedded in a Java App.


Solution

  • You can use System property nashorn.args to pass options to script engine instances created programmatically. See also: "setting options for Nashorn script engine" section at https://wiki.openjdk.java.net/display/Nashorn/Nashorn+jsr223+engine+notes