1

I'm running a Java application from withing a Matlab program. This Java program creates a csv as output file which I will process in Matlab.

I run the java program using system('java -jar application.jar')

Now I'm wondering, is there any way to detect from within matlab when this java application is closed?

Something like

while (system('java -jar application.jar'))
%wait
end
%application executed

The example above does not work for me.

Kaj
  • 2,445
  • 3
  • 23
  • 34
  • The `system` function is blocking, meaning that the execution of your program will halt until system finishes running your java application. Thus, no need to wait for it explicitly. –  May 21 '15 at 16:39
  • @CST-Link For some programs it's blocking, for others it's not. See for example [this answer](http://stackoverflow.com/a/27933690/2586922) – Luis Mendo May 21 '15 at 16:58
  • @LuisMendo Thanks for the reply. If I get it correctly, if the program "detaches" itself from the shell, then the MATLAB execution resumes immediately after. If not, `system` waits for the execution to end. In this case `cmd` (i.e. `system`) launches `java` with some stuff. Now, if I close `cmd`, my running java program will be forced to terminate also, right? which means that is not detached from the console; which means that is blocking. Or is it? –  May 21 '15 at 17:18
  • @CST-Link Actually I couldn't find any pattern as to when it is detached and when it is blocking. For example, WinRAR is not a console program. I would have expected it to be non-blocking. But it turned out to be blocking (at least in Windows 7) – Luis Mendo May 21 '15 at 18:52

0 Answers0