I have two java application running on my linux(centos)
system.first application done the processing and 2nd application CONTROLS 1st application.
Control Meaning (Perform operation on 1st application initiated from 2nd app ):
- START
- STOP
- RESTART
My 1st Application runs on static port 10001
How can i perform these operation from my second application ? I found this articles which get me somewhat closer.
https://stackoverflow.com/a/14340719/1169180 & https://stackoverflow.com/a/138098/1169180
How can i get PID
of application which is running on Port (10001)
?
Code :- eSocketServer.jar is my 1st application jar file
Process p = Runtime.getRuntime().exec(
"ps -ef | grep eSocketServer.jar | awk '{print $2}'");
BufferedReader br = new BufferedReader(new InputStreamReader(
p.getInputStream()));
while ((br.readLine()) != null)
System.out.println("line: " + br.readLine());
p.waitFor();
System.out.println("exit: " + p.exitValue());
p.destroy();
It doesnt giving me any output by when same command is executed by shell prompt ps -ef | grep eSocketServer.jar | awk '{print $2}'