Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import jdk.nashorn.api.scripting.NashornScriptEngine;

import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Main {
    public static void main(String[] args) throws ScriptException, NoSuchMethodException {
        NashornScriptEngine engine = (NashornScriptEngine) new ScriptEngineManager().getEngineByName("nashorn");
        engine.eval("load('res/nashorn8.js')");

        engine.invokeFunction("evaluate1"); // [object global]
        engine.invokeFunction("evaluate2"); // [object Object]
        engine.invokeFunction("evaluate3", "Foobar"); // Foobar
        engine.invokeFunction("evaluate3", new Person("John", "Doe")); // [object global] <- ???????
    }

}