This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arguments of System.exit()

 
Krishna Acharya
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
Is there anybody to help me in clearifying the no of arguments that system.exit() can hold. For eg. System.exit(0), System.exit(1). In which circumstances we use System.exit(1)? Are there other arguments besides 0 and 1.

Thanks
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit only takes one parameter. You can make that parameter any int you want. Typically, you make it 0 to indicate that the program will exit normally. You make it a non-zero value to indicate there was a problem.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you call your Java program from a shell script (in Unix) or a batch file (in Windows), you can check the return value, which is the value you pass to System.exit(...), in the script or batch file.

Most Unix and Windows programs that return a value like this, return 0 when there's no error and something else when there is some kind of error.

What value you should return depends on what you want to do in the script or batch file under certain conditions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic