This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number)" Watch "What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number)" New topic
Author

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

UdayK Kumar
Greenhorn

Joined: Aug 05, 2009
Posts: 26

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
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Have you read the javadoc for java.lang.System?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Here's a teaser:
The Java API wrote:The argument serves as a status code; by convention, a nonzero status code indicates...
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: What is the diff between System.Exit(0) or System.Exit(1) or System.Exit(Any Number)
 
Similar Threads
Difference between System.exit(0) and System.exit(1)
Number of weeks between two dates
exit statement in java
return() and System.exit()
System.exit(0) &System.exit(1)