File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.land.Runtime

 
Rich Stepanski
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found a couple different examples on how to execute a bat file from java.

basically..


I've tried command = a filepath , dos command, and only a file name (no directory)- all of which don't seem to work. The complete filepath doesn't throw an error but it also doesnt execute the bat, while the other two both throw an IO error. I'm using NetBeans 3.6 on XP - any idea what the problem is?
 
Rich Stepanski
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Runtime... not land.... too late now
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Batch files and DOS commands are not executable. They cannot be run on their own. They must be executed by the command shell, cmd.exe. try:

Keep in mind that the Process returned by exec() has a finite buffer for I/O, so you should really be reading from its input and error streams, otherwise your process may halt without warning. Not to mention the output could be useful for debugging.
 
Rich Stepanski
Ranch Hand
Posts: 59
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://mindprod.com/jgloss/exec.html

I found some help here - I dont really understand what the /E:1900 is but I guess I'm runnin the bat through the cmd.exe like you suggested. This begins to open the program but wont fully open it until I close my java app? I'm still not reading any of the output from the program - could this be the cause?

Note: Program runs after I close my app - doesn't crash. Also, the bat I am running opens another Java application.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic