File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes [URGENT PLEASE]Running a batch file through java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "[URGENT PLEASE]Running a batch file through java" Watch "[URGENT PLEASE]Running a batch file through java" New topic
Author

[URGENT PLEASE]Running a batch file through java

Anirban dutta
Ranch Hand

Joined: Aug 08, 2002
Posts: 89
How do I run an batch file ,which takes parameters, through Java?
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1815
Try:


See the documentation for the Runtime class for more information.
However, I seem to recall running into a problem where this would not work for batch files for some reason (this was versions of Java ago; I don't remember the reason). I used the JNI and created a native method that simply wrapped C's sytem(char*) function. That worked nicely.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

However, I seem to recall running into a problem where this would not work for batch files for some reason (this was versions of Java ago; I don't remember the reason).

It'll work. You must consume everything from the created process' stdout and stderr streams or the process will lock up.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: [URGENT PLEASE]Running a batch file through java
 
Similar Threads
run a java program via a batch file wich is called through the cgi of web server
Java Compiler and Run times(Urgent)
Installing EAR Through Program Problem..
How to create a batch file of java application?.
java program that can run a .class file in msdos, is this possible?