Lets say I have 2 individual java applications javaapp1 and javaapp2.
from javaapp1, I am executing a .bat file (which is responsible for starting javaapp2).
javaaap1 and javaapp2 are independent to eachother.
Suppose I am doing it with process.exec or processbuilder.
Now my question is:
-
What does exitCode means in this case if its not 0.Does it mean that something went wrong in executing batch file
or in the code of javaapp2? or both? -
Is it possible to capture errors from javaapp2 in javaapp1?If yes: How? Since i am not calling classes of javaapp2 directly.
-
Is javaapp2 errors and output are to be handled by javaapp1?
The exitcode will be whatever the other Java application has returned on
System#exit()call. If you’re executing it through abatfile, you need to ensure that it passes it back correctly.You can let it write to stdout or stderr, it will then by available by respectively
Process#getInputStream()andProcess#getErrorStream().If it contains code to handle the results mentioned by 1) and 2) correctly, then yes.
Related articles: