aspose file tools
The moose likes Java in General and the fly likes exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "exec()" Watch "exec()" New topic


Sandeep Advani
Ranch Hand

Joined: Mar 11, 2004
Posts: 78
Can I compile a .java file using Runtime.getRuntime().exec("javac")? If not, is it possible to do the same?

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12912
It is a bit more complicated than that - you have to consume the stdout and stderr character streams. Read the java.lang.Process JavaDocs.
The use of exec comes up frequently - search the ranch archives.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Or put tools.jar into your classpath, and use the Compiler.class inside.
Consider Paul's rocket mass heater.
subject: exec()