Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exec()

 
Sandeep Advani
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I compile a .java file using Runtime.getRuntime().exec("javac Test.java")? If not, is it possible to do the same?

Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Bill
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or put tools.jar into your classpath, and use the Compiler.class inside.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic