Problem : How do I compile a Java string and get teh class file
Consider this class.Just a sudo codes.........
public class MainClass {
public static void main(String[] args) {
//s is stored in a database
String s1=getStringFromBatabase(s);
//Consider s="class Hello{ public static void main(String[] args){
System.out.println(2);}}"
s2=compile(s1);
execute(s2);
}
}
//op is equal to 2
note:
String "s" is stored in a database.First we need to retreive it.Say s="class
Hello{ public static void main(String[] args){ System.out.println(2);}}"
Then wot i need is, compile this string without write it into a file.