I have a C# app that runs a jar file and uses the System.exit code as a return value. A console window is displayed as a part of this jar, and if the user closes it (thereby terminating the jar) it returns an exit code of 143. The problem is that 143 (or any positive integer) could be a valid exit code if the jar completes successfully.
I need a way to manually set the System.exit code to a negative integer. Treating 143 as an exception in the C# app is out of the question.
As in Diego Dias answer,
If you really want to ignore that, and both the Java and the C# apps are in your hand, an easy workaround is to add
1000to yourSystem.exitreturn value in Java, when the jar completes.Your C# application will recognize the successful execution by a return code
>= 1000and subtract it again.143is below1000and thus an error.