-
problem with Invoking .bat from java
Hi
I am trying to invoke a run.bat from java but I am not getting expected result, this is the java code
Java Code:
public class test {
public static void main(String args[]){
try{
Runtime.getRuntime().exec("cmd /c E:\\test\\run.bat");
} catch(Exception e){
System.out.println(e.getMessage());
}
}
}
The run bat file is
CD E:\quotes
ant full > e:\test.txt
when I click on that batch file it works fine and gives 6kb test.txt file, when I invoke from java program it gives 0kb
please any body help me...............
-
RE: problem with Invoking .bat from java
Searched the web, found an example with...
===
try {
Process p = Runtime.getRuntime().exec("test.cmd");
p.waitFor();
System.out.println(p.exitValue());
}
catch...
===
Notice the "waitfor"
Most likely your code is continuing before the the external process
is completed?
*
Similar Threads
-
Replies: 3
Last Post: 03-21-2007, 03:28 PM
-
Replies: 2
Last Post: 06-14-2006, 03:16 PM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Lori Piquet in forum Talk to the Editors
Replies: 114
Last Post: 10-10-2002, 06:01 AM
-
By Anonymous in forum Java
Replies: 0
Last Post: 01-31-2002, 11:08 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks