Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running Programs from JAVA Programs

 
Parth Sagdeo
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How would one run another program from a JAVA program. For example, how would one code a program open a web browser or compile another JAVA file?
Sincerely,
Parth
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The short answer to this question is that you use the command:

Runtime.getRuntime().exec("javac MyClass.java");

However there are some pitfalls and things to be aware of in running this. Here's a link to an article that explains some of them:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Good Luck.

Merrill
 
Surasak Leenapongpanit
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to compile the other classes at runtime, see Compiler class in Java API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic