-1

Possible Duplicate:
Executing another java program from our java program

I wanted to execute another java program from our java program. When i run a java program called 'First.java', it should prompt the user to enter the name of any class name(.java file name) and then it should read that input(.java file) and should be able to compile and run that program.Can anyone give me a sample code for that?

Community
  • 1
  • 1
Venkata
  • 31
  • 2
  • 7

1 Answers1

2

To compile a Java class, either invoke "javac" on it using Runtime.exec or look at the JavaCompiler API. To run it, invoke "java" on it (if it has a main method) or load it into your current Java process with an URLClassLoader.

mpartel
  • 4,474
  • 1
  • 24
  • 31