Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java exit codes and meanings

Is there a list of exit codes and meanings for java process terminations? Because I have an exit code 23 and i don't know what it can be (I cannot change the log to see the full stack trace because it sits in a different remote server).

I browsed it for hours and couldn't find any mentioning of exit code 23.

like image 482
Assaf Avatar asked Jun 23 '11 12:06

Assaf


People also ask

What are the exit codes in Java?

This status code is an integer value and its meanings are as follows: exit(0) - Indicates successful termination. exit(1) - Indicates unsuccessful termination. exit(-1) - Indicates unsuccessful termination with Exception.

What does exit 1 do in Java?

exit function has status code, which tells about the termination, such as: exit(0) : Indicates successful termination. exit(1) or exit(-1) or any non-zero value – indicates unsuccessful termination.

What do exit codes mean?

An exit code or exit status is a number that is returned by an executable to show whether it was successful. This is also sometimes called a return code, or in some cases, an error code, although the terminology here may be slightly different.

What can I use instead of system exit in Java?

The main alternative is Runtime. getRuntime(). halt(0) , described as "Forcibly terminates the currently running Java virtual machine". This does not call shutdown hooks or exit finalizers, it just exits.


2 Answers

In your Java application, when you call System.exit(n);, then the Java runtime environment will return n as the exit code back to the operating system.

What the number means depends on the program you are running - not Java itself, but the program you are running produces this number. There are no standard numbers. Look in the documentation of the program that produces this exit code to find out what it means.

like image 139
Jesper Avatar answered Oct 21 '22 08:10

Jesper


There is no definition for what exit code 23 means. Exit codes have no convention on what the values represent other than that a nonzero status code indicates abnormal termination. Zero indicates success but even then it is completely dependent as to whether the developer adheres to this 'standard'.

like image 21
Mike Kwan Avatar answered Oct 21 '22 08:10

Mike Kwan