Is it possible to enable one js from another with java nashorn engine?
ScriptEngine engine = new ScriptEngineManager().getEngineByName("Nashorn"); InputStreamReader rs = new InputStreamReader(new FileInputStream(new File(.../script.js)); engine.eval(rs);
script.js
var System = Java.type('java.lang.System'); // document.write("./test.js"); - javax.script.ScriptException: ReferenceError: "document" is not defined // require('./test.js'); - require is not defined
test.js
System.out.println("reading test.js file");
I want to create a top level script (in this example its script.js) and use it as a library for other scripts in the same directory.
java javascript scope nashorn
hnnn
source share