I've done some searching, and it seems a few people have asked similar questions, but none of them were quite what I was looking for (some suggested some scripting stuff but i didn't have enough knowledge of what i was doing so i want to use java only if possible).
I need to be able to read lines of code from a String, and then execute them in Java (like this):
String code = "System.out.println(\"Test code\");";
A lot of people reading this post might ask why don't you just execute
System.out.println("Test code");
but I want to execute code other than the println method from Strings.
Is it possible to execute code using java alone, if so how would it compile??