control-M for Web Services ,Java and Messaging (WJM, formerly BPI) allows Control-M to run Java applications.
Simply returning the code (0 or 1 or whatever) is not enough to determine whether the job actually fails or succeeds:
1Java methods can return any type of value which can have any meaning the developer wants. Best practice for Java programming is to use Exception handling if there is a failure. For more information, please refer to following link:
2. The Control-M Java CM (the caller) is a generic invoker and it does not know the meaning of the returned value from Java methods. So long as the invokation of the Java method was successful and there was no Exception thrown, then the CM will assume the job is OK.
If you would like Control-M to declare that the invokation should return NOTOK if the actual Java application fails, then you can do any of the followings:
a) Have your method returns a string, such as "Invokation failed". Then, add ON STMT processing to the CM job definition to declare job as NOTOK when encountering the "Invokation failed" statement.
b) Have your Java method thrown an Exception if it fails.
c) Place the method logic in the main() function with a call to System.exit(1) and set the CM job definition to invoke the main() method instead.https://crbtech.in/java-training/top-ja ... nt-in-pune