ScriptEngineManager: getEngineByName(String shortName) : ScriptEngineManager « javax.script « Java by API






ScriptEngineManager: getEngineByName(String shortName)

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

public class Main {

  public static void main(String[] args) {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("js");
    String script = "print ('www.java2s.com')";
    try {
      engine.eval(script);
    } catch (ScriptException e) {
      e.printStackTrace();
    }
  }
}

   
    
    
  








Related examples in the same category

1.new ScriptEngineManager()
2.ScriptEngineManager: getEngineByMimeType(String mimeType)