J
jds
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.
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.