• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

To close an application that has been opened previously

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I close an application, which I have opened before using java. Say, if I have opened a notepad or an InternetExplorer using
Process P=Runtime.getRuntime().exec("notepad.exe");
or
P=Runtime.getRuntime().exec("C:/Program Files/Internet Explorer/iexplore.exe www.yahoo.com");

and after 15 sec I want to close my application automatically through my code.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at Timer class or the Thread to achieve it.
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To close the other application, take a look at the API for Process.
I'm sure you'll find an appropriate method.

To do something 15 seconds later, you can use java.util.Timer and TimerTask
[ November 28, 2005: Message edited by: Jeff Albrechtsen ]
 
Rana Datta
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeff Albrechtsen:
To close the other application, take a look at the API for Process.
I'm sure you'll find an appropriate method.

To do something 15 seconds later, you can use java.util.Timer and TimerTask

[ November 28, 2005: Message edited by: Jeff Albrechtsen ]



Thanx, I could do it by Process.destroy() after the call of the application and then putting Thread.sleep(15000)
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can use sleep, but make sure that the delay isn't postposing other
actions that thread wants to carry out. That's why two posts suggested Timer.
You can also make your timer run in a daemon thread, if that is appropriate.
 
today's feeble attempt to support the empire
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic