I think out two method to resolve this question but they can't reach the expectation .
- I use the 'Process' to exec "ps -ef" - I can through this method to get all lines and I can filter them by my running command.But If I have many same command process.This isn't work. 
- I use the JNA to get PID 
    Field field = null;
    Integer pid = -1;
    try {
        Class clazz = Class.forName("java.lang.UNIXProcess");
        field = clazz.getDeclaredField("pid");
        field.setAccessible(true);
        pid = (Integer) field.get(process);
    } catch (Throwable e) {
        e.printStackTrace();
    }
This way only can get the PID of running window. It isn't the true PID of process.
what should I do?
Thanks!
 
     
    