java中用eval
package com.xuz.csdn.june16;import javax.script.ScriptEngine;import javax.script.ScriptEngineManager;import javax.script.ScriptException;public class ScriptEngineTest { public static void main(String[] args) { ScriptEngineManager sem = new ScriptEngineManager(); ScriptEngine se = sem.getEngineByName("js"); try { System.out.println(se.eval("1+2*(3+4)").toString()); } catch (ScriptException e) { e.printStackTrace(); } }}