In addition to the scripting support added in newer versions of Java, you can use the Bean Shell , which can even be used with older versions of Java, such as 1.5. Using Bean Shell, you can simply:
Object result = new bsh.Interpreter().eval(script);
Bean Shell - A fully compatible Java scripting engine for evaluating scripts and is used by Apache, Sun, Bea in their many products.
source
share