Here you can find the source of eval(String script)
private static String eval(String script)
//package com.java2s; //License from project: Open Source License import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main { private static String eval(String script) { ScriptEngineManager sem = new ScriptEngineManager(); ScriptEngine se = sem.getEngineByName("javascript"); String res = ""; try {// www. j a v a 2 s. c o m res = String.valueOf(se.eval(script)); } catch (ScriptException e) { e.printStackTrace(); } return res; } }