ScriptEngine

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();
		}
	}

}
 

你可能感兴趣的:(script)