siddharth gupta
siddharth gupta

Reputation: 305

Browser close event by Process

I am using a Process to open Internet Explorer or any other browser and then I want to go into an infinite loop until the browser is closed such that:

Process p = Runtime.getRuntime().exec(
    "C:\\Program Files\\Internet Explorer\\iexplore.exe");
while(true)
{
    if(p.browserclosed)
    break;
}

Can any one help me with this event so that I could know when the browser is closed, or there is any other method for this? In future I'm going to go to one specific JSP on the browser.

Upvotes: 1

Views: 113

Answers (1)

Stephan
Stephan

Reputation: 43053

I would use the waitFor method in this case.

Excerpt:

Causes the current thread to wait, if necessary, until the process represented by this Process object has terminated.

Full reference: http://docs.oracle.com/javase/7/docs/api/java/lang/Process.html#waitFor%28%29

Upvotes: 2

Related Questions