Here you can find the source of compile(ScriptEngine engine, String script)
public static CompiledScript compile(ScriptEngine engine, String script) throws ScriptException
//package com.java2s; //License from project: Apache License import javax.script.Compilable; import javax.script.CompiledScript; import javax.script.ScriptEngine; import javax.script.ScriptException; public class Main { public static CompiledScript compile(ScriptEngine engine, String script) throws ScriptException { if (engine instanceof Compilable) { Compilable compEngine = (Compilable) engine; return compEngine.compile(script); }//from w ww.j av a 2s .com return null; } }