I am trying to find a way to programmatically open and close an application. I easily run the application using
Runtime.getRuntime().exec(new String[] {"open", "<path to application>"});
however, the only way I can close it is to use the line
Runtime.getRuntime().exec(new String[] {"kill", "<process id#>"});
and I still canβt find the identifier #, except manually opening the terminal, and use the top one to find #. If there is a programmatic way to get this identifier or just the best way to open and close applications, I would like to hear about it.
thanks
source share