Run contents of string in java -


this question has answer here:

lets have string: string run = "system.out.println\(\"hello\"\)". want run in string output hello in console. maybe there method string.run()?

try beanshell , build app jar library.

import bsh.interpreter; private void runstring(string code){         interpreter interpreter = new interpreter();     try {          interpreter.set("context", this);//set variable, can refer directly string          interpreter.eval(code);//execute code     }     catch (exception e){//handle exception         e.printstacktrace();     } } 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -