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

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>
BrianMc1958Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
You can use that, but 0 is the error condition for *no* error. This is ringing a bell..?
0
 
CEHJCommented:
That really is the standard btw
0
 
petmagdyCommented:
Hi BrianMc1958,
> System.exit(0)
why not just return from the main method

Cheers!
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
BrianMc1958Author Commented:
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
 
CEHJCommented:
>>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
 
BrianMc1958Author Commented:
OK! Thanks!
--BrianMc1958
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.