Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 698 | Replies: 2
![]() |
•
•
Join Date: Apr 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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.
•
•
Join Date: Apr 2006
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
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.
[inlinecode]
String[] args1 = new String[2];
args1[0] = "copyTriple.triple";
// "copyTriple.triple";
args1[1] = "Ignored arguments";
System.out.println("Calling commandline main");
Commandline.main(args1);
try {
Runtime rt = Runtime.getRuntime();
String[] args2 = { "xsbexec.bat" };
rt.exec(args2);
fout1.close(); p1.close();
boolean success = (new File("copyTriple.triple")).delete();
if (!success) {
System.out.println("copyTriple not deleted");
}
System.out.println("done");
}
catch (IOException ioe) {
System.out.println(ioe);
}
[\inlinecode]
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.
exit
Thanks a tonne!
[inlinecode]
String[] args1 = new String[2];
args1[0] = "copyTriple.triple";
// "copyTriple.triple";
args1[1] = "Ignored arguments";
System.out.println("Calling commandline main");
Commandline.main(args1);
try {
Runtime rt = Runtime.getRuntime();
String[] args2 = { "xsbexec.bat" };
rt.exec(args2);
fout1.close(); p1.close();
boolean success = (new File("copyTriple.triple")).delete();
if (!success) {
System.out.println("copyTriple not deleted");
}
System.out.println("done");
}
catch (IOException ioe) {
System.out.println(ioe);
}
[\inlinecode]
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.
exit
Thanks a tonne!
•
•
•
•
Originally Posted by sidereal
post the code
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode