File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Forcibly Shutting Java Program Down Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Forcibly Shutting Java Program Down " Watch "Forcibly Shutting Java Program Down " New topic

Forcibly Shutting Java Program Down

Seth Burleigh

Joined: Jul 25, 2009
Posts: 7
I have a program (actually an eclipse plugin) that has to shut down a program even if it becomes frozen and the user has to use ctrl+alt+delete. If the java program is
shut down using this and the java program doesn't shut down a certain program that it was using via a socket (sbcl.exe), sbcl.exe suddenly starts sucking down resources (50 percent
or more of cpu). I don't want the user to have to use ctrl+alt+delete to shut down sbcl also. So my question is, is there anyway to make sure that this program shuts down when the java program shuts down (forcibly)?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

When you forcibly stop a program, that program doesn't get any chance to do anything before the operating system stops it. There is nothing you can do inside your Java program to make it stop the other program (sbcl.exe) when the Java program is forcibly stopped.

What you could do is make a small third program, which periodically checks if the Java program is still running or if it has been shut down cleanly. If it isn't running and hasn't shutdown cleanly, then that third program kills sbcl.exe.

Don't you have the source code of sbcl.exe? Isn't it strange that it starts sucking up resources if the Java program isn't running?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Seth Burleigh

Joined: Jul 25, 2009
Posts: 7
Ya, it is strange, but sbcl.exe is a reputable open source software. And I can run it outside my java program, and it doesn't suck down resources. So i think it is safe. Thanks, i will try that solution.
I agree. Here's the link:
subject: Forcibly Shutting Java Program Down
It's not a secret anymore!