![]() |
Calling a Batch file from Java using the exec command.
I am trying to call a batch file from java and expect the batch file
to be executed, but the exec command just comes back without doing anything. I am working on Windows2000 jdk1.3.1_03. I am truly baffled- has to be something elementary that I am missing here. Any input will be helpful. Thanks, jds. 1. Here is the test program test.java --------------------- import java.io.*; class test{ public static void main(String args[]) { try { System.out.println("Running the batch script"); Runtime.getRuntime().exec("test.bat"); System.out.println("Finished running the batch script"); } catch(Exception e) { System.out.println("Error creating the FileInfo panel: " + e); e.printStackTrace(); } } } --------------------- 2. Here is the result of the java run C:\>javac test.java C:\>c:\jdk1.3.1_03\bin\java.exe -classpath . test Running the batch script Finished running the batch script * No notepad was launched 3. Here is test.bat --------------------- echo "testing" echo "testing again" CALL notepad -------------------- 3. Here is the output of test.bat C:\>test.bat C:\>echo "testing" "testing" C:\>echo "testing again" "testing again" C:\>CALL notepad C:\> * Notepad was launched. |
Re: Calling a Batch file from Java using the exec command.
jaidev_sharma@yahoo.com (jds), Wed, 02 Jul 2003 13:29:21 -0700:
> I am trying to call a batch file from java and expect the batch file > to be executed, but the exec command just comes back without doing > anything. I am working on Windows2000 jdk1.3.1_03. I am truly baffled- > has to be something elementary that I am missing here. Any input will > be helpful. http://groups.google.nl/groups?q=bat...=Google+zoeken I think you're path settings are wrong. (just see the previous posts) greets. Bhun. |
hey you guys!! i fount an amazing new way to wait for the thread to stop by itself :)
do this: Code:
Process process = ... |
Quote:
|
Hey, Please can you explain it with an example...please...please...please...
|
| All times are GMT. The time now is 12:02 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.