I want to develop a java program which takes another java program as input and executes the input java program.Can anyone please suggest me how to do it?Thanks.
Amod Gupta wrote:I want to develop a java program which takes another java program as input and executes the input java program.Can anyone please suggest me how to do it?Thanks.
It looks like you want to develop another JVM in Java why do you want to do that? what do you want to?
Amod Gupta wrote:no i dont want to develop a jvm what i want to do is take a java program as input compile the input program and execute it from my main program only.
You want to do something like
Or you want to take java code as input and compile that code in side of the Main class??
What Bhagat Singh Rawat proposed won't help you, that code shows you how to dynamically load a class - but the class will have to be compiled beforehand.
By "input program", do you mean the source code? If so, that's just a string, so any character field should do. If you mean the class file, then you need a BLOB field. Search the JDBC forum (and the Sun Java Tutorial) for how to use either of those.
Ulf Dittmer wrote:By "input program", do you mean the source code? If so, that's just a string, so any character field should do. If you mean the class file, then you need a BLOB field. Search the JDBC forum (and the Sun Java Tutorial) for how to use either of those.