Global Scope and Engine Scope Bindings

This post explains about bindings and how we can use them to pass java objects to the script code. Java Scripting API provides map data structure which can be accessed, modified using Bindings Interface. The map entry’s key matches with the variable name in the script and their value can be a primitive value or…… Continue reading Global Scope and Engine Scope Bindings

Executing compiled script

In the previous posts under “Java Scripting”, we used ScriptEngine eval method to execute scripts stored in a string variable or file. The ScriptEngine’s eval methods takes the script compiles to intermediate code and execute it immediately. If we have a script which has to be executed repeatedly, then instead of compiling and executing it…… Continue reading Executing compiled script

Executing scripts written in a file using java

This post explain how to execute javascript code stored in a file. We create an instance of FileReader representing the physical file and pass it to eval method of an instance of ScriptEngine. Please refer to previous posts to know more about ScriptEngine and ScriptEngineManager The javascript code in the file that has to be…… Continue reading Executing scripts written in a file using java