Java tutorial
import javax.script.Bindings; import javax.script.ScriptContext; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main { public static void main(String[] args) throws ScriptException { ScriptEngine jse = new ScriptEngineManager().getEngineByName("javascript"); Bindings bindings = jse.getBindings(ScriptContext.ENGINE_SCOPE); Main test = new Main(); bindings.put("test", test); String preFix = "demo"; jse.eval("test." + preFix + "_test()"); preFix = "actual"; jse.eval("test." + preFix + "_test()"); } public void demo_test() { System.out.println("demo test"); } public void actual_test() { System.out.println("actual test"); } }