-2

I am trying to work out why should we inform the JVM with exit status values, like 0 or 1.

What is the need?

For example:

class sample
{
    public static void main (String args[])
    {
        System.out.println("Calling System.exit()");
        System.exit(0);
    }
}
Tiz
  • 680
  • 5
  • 17
Vignesh
  • 31
  • 8

1 Answers1

1

The exit code is not for the JVM. It is for the user / system running the program.

An exit code of 0 indicates that the program executed fine. An exit code of anything else represents an error. As the developer you can decide what the different codes mean, for example you could decide that a code of 4 meant a database error caused the exit.

You can find a bit more information here.

Community
  • 1
  • 1
Tiz
  • 680
  • 5
  • 17