How could I call Java code dynamically?
问题 How could I write Java code that is executed like javascript code used together with the eval function? What I would like to achieve would be something like this: System.execute ("String str = \"test\"; System.out.println(str);"); which would print the word 'test'. (10x dehmann ) A code sample would help a lot. 回答1: Look into BeanShell or Groovy. Both will give you reasonable solutions--but those solutions rely on my interpretation of your problem, which may be flawed. 回答2: I've used the