• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.land.Runtime

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.lang.Runtime... not land.... too late now
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic