Here you can find the source of eval(String name, Map
public static Object eval(String name, Map<String, Object> params) throws ScriptException
//package com.java2s; //License from project: Open Source License import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.script.Bindings; import javax.script.CompiledScript; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main { private static ScriptEngine engine = new ScriptEngineManager().getEngineByName("js"); private static Map<String, CompiledScript> scripts = new ConcurrentHashMap<String, CompiledScript>(); public static Object eval(String name, Map<String, Object> params) throws ScriptException { CompiledScript script = scripts.get(name); if (script == null) { throw new ScriptException("no such methor!"); }//from ww w . j a va 2s . c o m Bindings b = engine.createBindings(); if (params != null) { b.putAll(params); } return script.eval(b); } }