- public static java.lang.Object eval(java.lang.String script)
Evaluates a JavaFX Script source string and returns its result, if any.
Evaluates a JavaFX Script source string and returns its result, if any. This method depends upon the JavaFX Script compiler API being accessible by the application, such as including the
javafxc.jarfile in the application's classpath.
This method also depends upon the JSR-223 API classes being accessible by the application, such as including the
script-api.jarfile in the application's classpath or the application must be run on JDK 6+ where JSR-223 API classes are part of the platform API. For JDK 5, script-api.jar has to be in application's classpath.
Note: This method provides only the simplest scripting functionality; the script is evaluated without any specified context state, nor can any state it creates during evaluation be reused by other scripts. For sophisticated scripting applications, use the Java Scripting API (
Note: On Mac platform, javafxc.jar, javafxrt.jar and script-api.jar have to be prefixed in bootclasspath for this API to work. This is because on Mac, javac classes are in bootclasspath. But, javafxc re-implements certain javac classes differently. The version of javac classes from javafxc.jar should take precedence over the ones from the platform javac's jar. The javafx command line goes like:
javafxc -Xbootclasspath/p:<javafxc.jar-path>:<javafxrt.jar-path>:<script-api.jar-path> -cp <app-class-path> <app-main-class>
- the JavaFX Script source to evaluate
- the results from evaluating the script, or null if no results are returned by the script.