Exécuter un Script à l’aide de Moteur de script

Author:


{filelink=936}

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

public class ExecuteJScript {

    public static void main (String[] args) {
        ScriptEngineManager manager = new ScriptEngineManager ();
        ScriptEngine engine = manager.getEngineByName ("js");
        String script = "print ('Bonjour javaScript')";
        try {
            engine.eval (script);
        } catch (ScriptException e) {
            System.out.print(e.getMessage());
        }
    }
}
//Bonjour javaScript

Leave a Reply

Your email address will not be published. Required fields are marked *