• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number)

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can you please let me know...

What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number) in Java?



Uday
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you read the javadoc for java.lang.System?
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a teaser:

The Java API wrote:The argument serves as a status code; by convention, a nonzero status code indicates...

 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The value means nothing for the Java program itself. The shell calling the Java program can use it to determine what to do next.

A small example of how I usually compile Linux programs from source and install them: These are three separate commands:
- ./configure reads my environment settings, and creates a build script (Makefile) based on them
- make uses the instructions in the generated Makefile to actually compile the code into an executable
- make install then installs the created executable into a specified location

The && work similarly to how they work in Java: if ./configure succeeds the shell will call make. If that too succeeds the shell will call make install. If ./configure fails (e.g. because a required library is missing) then the shell will abort and not call the remainder. Failure is usually indicated by a non-0 return (i.e. 0 is good, everything else is bad).
reply
    Bookmark Topic Watch Topic
  • New Topic