-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?

2
  • Correct duplicate question user call the main method from your class like FileName.main(null) Commented Oct 14, 2011 at 17:03
  • Take a look at stackoverflow.com/questions/502494/… Commented Oct 14, 2011 at 17:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.