We can open Notepad or Calculator or any application using Java Runtime say for example To open calculator we need to run below line of code in java.
Runtime.getRuntime().exec("calc");
but I want to do some action on closing the app that I opened through above line of code.
You can do something like this:
Process proc = Runtime.getRuntime().exec("calc");
proc.waitFor();
waitFor will wait for the termination of the application. If you don't want to wait, you can call proc.isAlive()
to test the process status. You can also start a java thread that will start the application and wait for it's termination.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.