java中使用js

import java.util.Scanner;java

import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException;code

public class test6 {ip

public static void main(String[] args) throws Exception {

	ScriptEngineManager se =new ScriptEngineManager();
	ScriptEngine s = se.getEngineByName("JavaScript");
	Object oj=s.eval("function add(a,b){return a+b};add(2,4)");
	System.out.println(oj);
	
}

}get

相關文章
相關標籤/搜索