This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to make a Runtime process to finish.? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to make a Runtime process to finish.?" Watch "how to make a Runtime process to finish.?" New topic
Author

how to make a Runtime process to finish.?

dharma lingam s
Greenhorn

Joined: Aug 29, 2013
Posts: 14
hi all,

i am running make command inside the Runtime.exec() command. but its not fully completed how to achieve this.



how to acheive this one. After the full completely execution of 'make' only it have to print. But its printing and exiting earlier. Any idea.???
Ganesh Gore
Greenhorn

Joined: Jan 03, 2011
Posts: 24

dharma lingam s wrote:hi all,

i am running make command inside the Runtime.exec() command. but its not fully completed how to achieve this.



how to acheive this one. After the full completely execution of 'make' only it have to print. But its printing and exiting earlier. Any idea.???



Simply add the below line....
p1.destroy();
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035
    
  10

You probably have a deadlock due to either the stdout or stderr buffers filling. When this happens the process is suspended until more buffer space is available but since you are not draining either of them the process cannot proceed. This is all explained in the 4 sections of http://www.javaworld.com/jw-12-2000/jw-1229-traps.html. You should ALL of read this and implement ALL the recommendations or you will suffer more grief.

Edit : I'm mystified as to why the OP has not already read the 'traps' article since I posted a reference to it in one of his other threads. I can only assume that he thinks he knows better and that he is immune to the traps. There is no point in me responding any further until I see evidence of the implementation of the 'traps' recommendations.
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035
    
  10

Ganesh Gore wrote:

Simply add the below line....
p1.destroy();


I don't think this will solve the OP's problem since it will abort the process without it actually running to completion. The OP almost certainly has a deadlock as I explained in my previous post..
dharma lingam s
Greenhorn

Joined: Aug 29, 2013
Posts: 14
destroy is forcibly terminating that also not working fully. At least any way the runtime(exec) process to run or other process to wait for its completion. atleast some seconds.


Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035
    
  10

dharma lingam s wrote:destroy is forcibly terminating that also not working fully. At least any way the runtime(exec) process to run or other process to wait for its completion. atleast some seconds.




Are you determined to ignore my advice ? Why do you bother asking questions here if you just ignore the responses?

Bye
dharma lingam s
Greenhorn

Joined: Aug 29, 2013
Posts: 14
Sorry, just i asked anyother way to achieve the exec("make") command. so only i did.

i getting exception. process hasn't completed. any way to sole this.
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1035
    
  10

dharma lingam s wrote:Sorry, just i asked anyother way to achieve the exec("make") command. so only i did.

i getting exception. process hasn't completed. any way to sole this.


I have told you what to do! Read the sodding 'traps' article and implement the recommendation. That is the only way to do it.
dharma lingam s
Greenhorn

Joined: Aug 29, 2013
Posts: 14
thanks Richard Tookey.. its working.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to make a Runtime process to finish.?
 
Similar Threads
Runtime in JSP
Problem reading database.
printStackTrace (); how do I see what it print?
Running external .exe from java not working in windows 7...
In Windows, how to measure any java program execution time from other monitoring java program ?