This question already has an answer here:
- Is there an eval() function in Java? 8 answers
I wish to, using Java, compile/build and run a piece of text that is code. When the run button is pressed in eclipse, the last class viewed with a public static void main (String[] args) { }
method is compiled and run. Is there any way to run regular text (which is proper Java code) from Java, either with an API or from a library?
NOTE: The text will always follow the following format:
public class NAME {
public static void main (String[] args) {
// Java Code
System.out.println("Java Code Like Usual!");
}
}
Aucun commentaire:
Enregistrer un commentaire