I am calling an external application from my Java GUI. The Java code is below when the user hits the “RUN” button in the GUI:
Runtime runme = Runtime.getRuntime();
runme.exec("MyApp.bin");
MyApp.bin does some math calculations and has some loops in it – no big deal. What happens is that MyApp.bin gets stuck! When I close my Java GUI, then MyApp.bin continues to run and finishes. If I run MyApp.bin directly from the terminal, then it runs fine without freezing. Why does my application freeze when it is run from the Java GUI, but resumes when I close the Java GUI? What is the Java GUI or Java code doing that is blocking my application from running successfully?
I’m going to make a wild guess that
MyApp.binis outputting something to its standard out, and you’re not reading it. This causes the buffer to fill, and blocks your process.Runtime.exec()returns aProcessobject. If you read the javadoc for that you’ll find:http://docs.oracle.com/javase/6/docs/api/java/lang/Process.html