wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes How to end Java Program? 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 » Beginning Java
Bookmark "How to end Java Program?" Watch "How to end Java Program?" New topic
Author

How to end Java Program?

Scott Kamen
Greenhorn

Joined: Apr 01, 2003
Posts: 15
I know this is incredibly easy and even though I'm not supposed to I still feel somewhat embarrassed asking it. How do you kill (quit) a java application? I had though that you could use kill(0); (or any number value) but I got a compile error. I did a quick look in the indexes of my books and on google but I didn't come up w/ anything. Could someone help me?
thanks,
-Scott
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
In simple circumstances, System.exit(int) should do it. So, would returning from the main method.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
If you are using a GUI (e.g. applet), you will need to use the System.exit that Dirk mentioned. Otherwise, the program should exit normally with no need for a specific command to exit.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Yes!
System.exit(0);
which can exit
and if your programme involves java swing of the GUI programme
you can type
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
which also can quit the application.
thank you


Francis Siu
SCJP, MCDBA
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
Do you read it?
I hope that it can help you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to end Java Program?
 
Similar Threads
How many nuclear warheads are required to destroy earth civilization?
Parallel Task
Dirty but Interesting
Trap system signals
got error while running weblogic from the unix environment