There is a task, you need to call the same bat file two times from java. Actually the solution that I have already found here

Runtime.getRuntime().exec("cmd /c FullFileName.bat"); 

The problem is that you have to do it in such a way as to prevent bat afqk from running a second time until the first one is finished. Design

  Runtime.getRuntime().exec("cmd /c FullFileName.bat").waitFor(); 

unfortunately does not help. Actually the question is where to dig?

UPDATE from the bat file I have another program twitching (Oracle forms). When I run the bat file from the command line, I clearly see that the bat file is waiting for the external program to finish. And here when from java the full sensation that does not wait. Because the result of the second program often overwrites the result of the first program. If you force a delay, then everything is OK

  • And actually, why waitFor does not help? This method waits for the process to complete and returns a return code. - Andrew Bystrov
  • @AndrewBystrov Well, I also thought so, but the reality turned out to be evil ... from the bat file I have another program twitching (Oracle forms). When I run the bat file from the command line, I clearly see that the bat file is waiting for the external program to finish. But when from java like that all is not obvious ... - plesser
  • And in your batch file, besides calling oracle forms, something else happens? - Andrew Bystrov
  • @AndrewBystrov yes, the file is transferred from one place to another - plesser
  • You can try using methods to capture the monitor (blocking the stream) like wait () notify () - Alex

0