package scriptengine;

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

/**
 * @Author: yoyo
 * @Description:
 * @Date: Created in 2019/9/4 10:38
 */
public class JavaJavaScript {
    public static void main(String[] args) throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("javascript");
        engine.eval("var x = 10;");
        engine.eval("var y = 20;");
        engine.eval("var z = x + y;");
        engine.eval("print (z);");    }
}

@@ -166,16 +166,186 @@
 ription:
+ Run Javascript from Java %3Clink%3Ehttps://javapapers.com/core-java/run-javascript-from-java/%3C/%3E%0A * Java 8 Features %3Clink%3Ehttps://javapapers.com/java/java-8-features/%3C/link%3E
 %0A * @Dat
@@ -754,16 +754,17 @@
  (z);%22);
+%0A
     %7D%0A%7D%0A

add link