• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Help with System.exit(0)"

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the error im getting when I try and run my java program in Dr java

"the interactions window was terminated by the call to System.exit(0)"

The program runs briefly and then closes, it works properly when I remove the System.exit(0)" what is the purpose of this command and why do the examples in the text book have it. Please look at the code below

____________________________________________________________________________
 
Marshal
Posts: 8513
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Meki Banda.

Please check how to UseCodeTags (<- link) properly. I see you tried, thank you for that.
 
Liutauras Vilda
Marshal
Posts: 8513
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meki Banda wrote:The program runs briefly and then closes, it works properly when I remove the System.exit(0)"


Please provide a bit more details based on that quoted sentence you wrote. What do you mean by program works properly when you remove System.exit(0)? What abnormal things happens with System.exit(0)?
 
Elim Banda
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:

Meki Banda wrote:The program runs briefly and then closes, it works properly when I remove the System.exit(0)"


Please provide a bit more details based on that quoted sentence you wrote. What do you mean by program works properly when you remove System.exit(0)? What abnormal things happens with System.exit(0)?

\

Try run the code in Dr Java it takes a few minutes to download. The program crashes abruptly and there is no time to see the output.
 
Liutauras Vilda
Marshal
Posts: 8513
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Meki Banda wrote:"the interactions window was terminated by the call to System.exit(0)"

I'm sorry, I completely missed that. I'm not sure about that error/information message, but I suspect this could be related with your programming environment DrJava which I have to admit never tried it.

About the System.exit used in particullary together with JoptionPane's you can google it, there are lots of answers. Please start here.
 
Elim Banda
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:

Meki Banda wrote:"the interactions window was terminated by the call to System.exit(0)"

I'm sorry, I completely missed that. I'm not sure about that error/information message, but I suspect this could be related with your programming environment DrJava which I have to admit never tried it.

About the System.exit used in particullary together with JoptionPane's you can google it, there are lots of answers. Please start here.



please look at the attachment
Capture1.PNG
[Thumbnail for Capture1.PNG]
 
Liutauras Vilda
Marshal
Posts: 8513
610
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I mentioned, it is just a information message. I see there is a tab "Console" at the bottom, so click that and likely you'll see your program's output.
The possible reasons of using or not using System.exit with JoptionPane please check in the google search link I provided. You could find long explanations of it.

Also you do have book where you found example which uses it. What is said in your book about it and which book you're reading?
 
Elim Banda
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:As I mentioned, it is just a information message. I see there is a tab "Console" at the bottom, so click that and likely you'll see your program's output.
The possible reasons of using or not using System.exit with JoptionPane please check in the google search link I provided. You could find long explanations of it.

Also you do have book where you found example which uses it. What is said in your book about it and which book you're reading?



Thanks for your help
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It may be worth mentioning that this is just one reason why it's generally NOT a good idea to use System.exit().

So perhaps it's worth asking: Why did you use it?

Winston
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic