Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var nonMath = function(){
- var num = 2;
- print("num : " + num); //prints 2
- return (num);
- };
- var doMath = function(){
- var num = Math.round(2.0);
- print("num : " + num); //prints 2
- return (num);
- };
- ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
- engine.eval(new FileReader("lib/script.js"));
- Invocable invocable = (Invocable) engine;
- System.out.println("nonMath : " + invocable.invokeFunction("nonMath")); //prints 2
- System.out.println("doMath : " + invocable.invokeFunction("doMath")); //prints 2.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement