This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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
 
 
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
Installing EAR Through Program Problem..
Java Compiler and Run times(Urgent)
How to create a batch file of java application?.
java program that can run a .class file in msdos, is this possible?