How to create an object from a string in Java (how to eval a string)? -
I know eval is "evil", but I'm using it in such a way that the user never fixes it can .
Say I got a new string "New Integer (5)". I want to do something like this that I can set a variable, let's say Fu, in the new integer (5) Something like
integer fu; String bar = "new integer (5)" * magic happens * System.out.println (foo) - & gt; 5
I have looked around and it seems that I have some options, can I get the GetSystemJavaCompiler () method in I ToolProvider? Or should I use Beanshell? Or something else? Note that this is a string, no file.
I would like to use a scripting language such as Binsal, Jruby, jython, etc.
Comments
Post a Comment