Our java program returns a status code at exit by doing
System.out.println(statusCode);
System.exit (statuscode);
The value goes back to the shell script (korn shell) where calls the java class. In the script it gets the return value by storing in a variable RETSTATUS as below -
$JAVA_HOME/bin java $SYSTEM_PARAMS -jar myclass.jar
RETSTATUS=$?
echo $RETSTATUS
Somehow the value printed in java is 400 (correct status code), but the value of RETSTATUS in script is 144 in echo. Any idea why and how to fix it? Thanks for any help in advance.
Exit codes in *nix are
short
s. When you return400
you overflow the return code (note that400-256=144
). Just return a sensible positive number of255
and below and you should be fine.