Return value from a Java code

Viewed 31001

There is a Java class which creates a POST request and sends it to a servlet. The main method of the class file (test) looks something like this:

public static void main(String[] args) throws IOException {
  // Code logic goes here...
  // No return Statement
}

This is called from a KornShell (ksh) script something like this:

retcode=`$CLK_JAVA_PATH -cp $CLASSPATH test ${PASSWORD} ${HOSTNAME} ${TOOLSET}`

if [ $? != "0" ];then
        echo "ERROR:  
        echo "${retcode}"
else
        echo "${SCRIPT} Success"
fi

retcode always has the value "2" independent of if the code fails or succeeds. My question is since the return type of my main method is "void" why is the code returning some value?

6 Answers
Related