Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Calling a Batch file from Java using the exec command. (http://www.velocityreviews.com/forums/t123988-calling-a-batch-file-from-java-using-the-exec-command.html)

jds 07-02-2003 08:29 PM

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.

dhek bhun kho 07-02-2003 08:34 PM

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.


pizzapie 09-11-2010 10:52 AM

hey you guys!! i fount an amazing new way to wait for the thread to stop by itself :)

do this:
Code:

Process process = ...
process.waitFor(); // waits for it to terminate


Nitin Yadav 10-03-2011 04:10 PM

Quote:

Originally Posted by pizzapie (Post 4128948)
hey you guys!! i fount an amazing new way to wait for the thread to stop by itself :)

do this:
Code:

Process process = ...
process.waitFor(); // waits for it to terminate


Hey, Please can you explain it with an example..please...please...please...:-)

Nitin Yadav 10-03-2011 04:12 PM

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.