I built a java program that runs the command "jps" and sees all JVMs and kills a particular JVM by extracting its id from the output of JPS command. It is working fine when I run it on the ubuntu terminal. But then I wrote a script in bash to ssh that machine from other machine and run this program there.
ssh $host "java -cp daemon.jar JVMname;"
Now here comes the problem.
Exception in thread "main" java.io.IOException: Cannot run program "jps": error=2, No such file or directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at runtime.daemon.halt.main(halt.java:19)
Caused by: java.io.IOException: error=2, No such file or directory at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1021)
If I go to the the machine myself and run this same command it works. I do not want to switch to exec solution.
Any ideas Thanks