Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Starting and Stopping an External Process

Thread view: 
DevNull - 16 Apr 2007 12:34 GMT
Hello Everyone,
After realizing I'm spending way to much time playing games I decided
to create a Tea-Timer application.
The purpose of the application is to launch another application such
as solitaire or wow or what have you.  Then countdown to a specified
time, and when the time limit is reached kill the game.

I have it all going now with the exception of killing the specified
game.
The assumption that I made (evidently a bad assumption on my part),
was that simply exiting the java app would kill the running child
app.  This does not seem to be the case.
Can anyone point me in the right direction on how best to kill off the
application once the time runs out?

Thanks in advance!
Oliver Wong - 16 Apr 2007 15:52 GMT
> Hello Everyone,
> After realizing I'm spending way to much time playing games I decided
[quoted text clipped - 10 lines]
> Can anyone point me in the right direction on how best to kill off the
> application once the time runs out?

   Try reading the javadocs for the classes you are using.

   For example, if you are using the Process class, you should read
http://java.sun.com/javase/6/docs/api/java/lang/Process.html

   - Oliver
alexandre_paterson@yahoo.fr - 20 Apr 2007 00:58 GMT
> Hello Everyone,
> After realizing I'm spending way to much time playing games I decided
[quoted text clipped - 5 lines]
> I have it all going now with the exception of killing the specified
> game.

So I assume you already now how to launch an external process
from Java...

> The assumption that I made (evidently a bad assumption on my part),
> was that simply exiting the java app would kill the running child
> app.  This does not seem to be the case.
> Can anyone point me in the right direction on how best to kill off the
> application once the time runs out?

If you're playing WoW on Linux or OS X,  "kill -9" will do the job
in a cruel way...  All you need to know is the PID of the process,
which you can easily find using the output of ps.

If you're on Windows, then I'd recommend the free and
excellent "pskill.exe" for http://www.sysinternals.com
(for pskill.exe you simply need the name of the process,
which should always be the same for, say, WoW).

I'm using it since years for several Windows version and it
works like wonder.

That said, launching a Java app and keeping a JVM running
just as a timer seems overkill.  I'd go with a bash/shell script
running in the background.
alexandre_paterson@yahoo.fr - 20 Apr 2007 01:03 GMT
replying to myself...

As explained in the Process JavaDocs, as you're in
control of the process you created Process's destroy()
method MAY do what you want.  However in won't
work for every process launched by Java' Process
facility (this is explained in the JavaDocs).

So, check if Process's destroy() method works *in
your case*...  Otherwise check kill / pskill.exe.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.