I am trying to execute a batch file which in turn executes an exe and writes output to a file, through java. I do not know why but the output file is not always written. Sometimes the program terminates without writing the file and sometimes it does. Any suggestions? Is there anyway i can wait till the execution of the batch file is complete?Will be great if somebody can help!thanks.

10 Years
Discussion Span
Last Post by uth

Thanks. The following code is inside a function within a class. Now there is an application called triple used for inferencing. It is an exe but I am not able to invoke it directly. Thats why all the hassle. It consists of two parts.The first part as shown below calls "Commandline" which generates a file. Then when I call the xsbexec.bat, it takes the file thats generated and uses it to generate an output. That i'm redirecting to another file.

String[] args1 = new String[2];

        args1[0] = "copyTriple.triple";
        // "copyTriple.triple";
        args1[1] = "Ignored arguments";
        System.out.println("Calling commandline main");
try {

            Runtime rt = Runtime.getRuntime();
            String[] args2 = { "xsbexec.bat" };
            fout1.close();  p1.close();
            boolean success = (new File("copyTriple.triple")).delete();
            if (!success) {
                    System.out.println("copyTriple not deleted");
        catch (IOException ioe) {

The following is what the batch file contains:

@echo off

rem adapt paths here

set XSB=C:\XSB\config\x86-pc-windows\bin\xsb
rem end adapt

echo running %1 %2 %3 %4 %5 %6 %7 %8 %9
%XSB% --nobanner --quietload --noprompt -e "['C:\Documents and Settings\Uthru\workspace\Patient records\#out']." >xsbex2.out

echo done.


Thanks a tonne!

post the code

Edited by diafol: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.