[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What is the industry-standard method of program to terminate itself?

Posted on 2005-05-16
7
Medium Priority
?
257 Views
Last Modified: 2010-03-31
Dear Experts,

I have a commercial single-threaded class that I want to have terminate itself--and it's JVM--under certain error conditions.  (In this case, I know the JVM isn't running anything else).  

Is System.exit(0) the standard way to do this?  BONUS: Should I use zero as parameter, or something else?

Thanks,
BrianMc1958


<subject altered by PashaMod>
0
Comment
Question by:BrianMc1958
  • 4
  • 2
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 14010330
You can use that, but 0 is the error condition for *no* error. This is ringing a bell..?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14010348
That really is the standard btw
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 14010377
Hi BrianMc1958,
> System.exit(0)
why not just return from the main method

Cheers!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:BrianMc1958
ID: 14010387
Dear CEHJ,

Thanks.  Regarding the bonus question, I guess I should have asked:  Will the System ITSELF do anything different if I feed it a non-zero value in exit()?  What is supposed to happen differently?

Thanks,
BrianMc1958
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14010422
>>Will the System ITSELF do anything different if I feed it a non-zero value in exit()?

No. But you should still observe the practice of returning a meaningful result, as any process that invokes your program may need to know this
0
 

Author Comment

by:BrianMc1958
ID: 14010478
OK! Thanks!
--BrianMc1958
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 14010527
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question