1

I am throwing an exit code from a java program with System.exit(int). Should I be able to see any message when the program exits this way? I see nothing at this point.

3 Answers 3

6

That's perfectly normal. You can look at the exit code of a command in Unix using $? in bash.

Sign up to request clarification or add additional context in comments.

Comments

3

The value returned by System.exit can be read by the operating system, and it's OS-specific how it's interpreted. In most UNIX-like systems, a program's exit code can be captured by other processes if they so choose, but nonzero return values don't cause the OS to print any error message. For example, the javac compiler will return a nonzero status code if the program fails to compile, but the OS won't print out any special error messages in this case. If you want to bring up some sort of error dialog, you will need to do so manually.

Hope this helps!

Comments

3

You have to examine $? after java exits to see the exit code. The shell does not print messages by default when a command returns a non-zero status.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.