包名:import javax.script.*;
使用:
String str="2+6%7";
ScriptEngine se=new ScriptEngineManager().getEngineByName("JavaScript");
try{
double d=(Double)se.eval(str);
double d=(Double)se.eval(str);
System.out.println("result="+d);
System.out.println("result="+d);
}catch(ScriptException e){
System.out.println("error");
}