Reputation: 57
I have been trying to run an executable file and waiting for it to finish running and it's in a loop so it runs multiple times. I just can't get it running and waiting. I have tried to add a buffer to my program as well stacktrace.
The file I want to run is an executable in my C drive as you can see below in my code. The executable grabs inputs from another text file, which is what I am modifying before I run the executable. The text file has more than 100 chemical species and over a thousand reactions that are ran through the executable. What I want to do is modify the inputs with the outputs produced from the executable. The funny thing is is that the executable outputs to the same file.
That was just to give some background on what the executable file does. That is why I have it in a loop because I am running these reactions at fractions of a second where I will grab the outputs and place them into another text file for later data analysis. But at the current moment it seems that all the methods and codes I have tried to get the executable just doesn't work, and it might even be because of the waitFor function. I just honestly don't know what else to do, and I don't know how to be more specific with my problem. I am a java newbie and need some guidance in what I will need to do to further my progress.
while(finalTime < 1.0){
try{
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec("C:file",
null, new File("C:file"));
int exitVal = pr.waitFor();
System.out.println("Exited with error code "+exitVal + "intital:" + initialTime + ", finalTime:" + finalTime);
pr.destroy() ;
}catch(IOException | InterruptedException pr){
pr.printStackTrace()
}
initialTime+= 0.10;
finalTime+=0.10;
updateTime();
}
any suggestions?
Upvotes: 1
Views: 1322
Reputation: 1022
Take a look at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
You probably fill up the buffer.
Upvotes: 2