Run piece of code contained in a String
java, reflection
Solution
As has already been suggested you can compile, save and run code on the fly using the Compiler API.
Another neat alternative would be to use beanshell. Beanshell is no longer actively developed, but I can vouch for it's reliability, I've used it successfully in multiple production projects.
Problem
I have a piece of Java code in a String. ``` String javaCode = "if(polishScreenHeight >= 200 && " + "polishScreenHeight <= 235 && polishScreenWidth >= 220) { }"; ``` Is it possible to convert this Java String to a Java statement and run it? Possibly using Java reflection?