Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   How to forcely quit a process in java (http://www.go4expert.com/forums/forcely-quit-process-java-t3440/)

ganesh_don 16Mar2007 20:21

How to forcely quit a process in java
 
Buddies... Actually i executed wget unix command using Runtime.exec() method and got the process object,now i want to forcely quit the running process as its taking much time to compleate,and i dont want to wait till it compleates.so how cud i forcely quit a process(similar to typing ctrl c in the terminal).please kindly help me.Thanks in advance...........

pradeep 17Mar2007 11:22

Re: How to forcely quit a process in java
 
You'll need the process id of the process, then use kill -9 [pid] to kill the process.

ganesh_don 21Mar2007 09:40

Re: How to forcely quit a process in java
 
OK MR.pradeep its fine,actually i cant use kill command bcoz i dont know the process id,anyhow leave it, now tell me how do i know whether this process is compleated or not.sorry for the late reply my internet is down for few days........Thanks for ur previous reply..........

ganesh_don 21Mar2007 12:04

Re: How to forcely quit a process in java
 
buddies i myself found the solution to check whether the process is compleated or not:

solution
Code:

try{
        Runtime rt = Runtime.getRuntime();
        Process p = rt.exec("some command");
        while(true)
        {
         
          try{
            if(p.exitValue()==0)
            {
                System.out.println("process terminated");
                break;
            }
          }
          catch(Exception e)
          {
            System.out.println("process in execution..............");
          }
       
        }
       
        }
       
        catch(Exception e)
        {
            e.printStackTrace();           
        }

if there is some other solution let me know...........

pradeep 21Mar2007 14:25

Re: How to forcely quit a process in java
 
Cool dude!

ganesh_don 22Mar2007 16:55

Re: How to forcely quit a process in java
 
Thankyou dude........


All times are GMT +5.5. The time now is 06:29.