How can I get the correct exit code from LSCM when calling from Java?
HI. . . I recently started using the Java runTime rather than ant to run lscm commands. Unfortunately, I can't seem to get the true exit value. It seems there are a ton of variables to this simple topic including how the java interpreter is called from the batch file, how the batch file exits, whether command extensions are used in the Windows command interpreter, and whether ProcessBuilder or runTime.exec() is used. There may even be more that I'm not aware of.
If I run the lscm command from the console and run "echo %ERRORLEVEL%", it looks accurate. But I haven't been able to get this exit value from my java code, it just returns 0 regardless of the success of the command.
Does anyone have a tried and true approach to calling lscm from Java and getting accurate exit values?
Thanks for your thoughts and help!
- Andy
|
One answer
You can use ProcessBuilder and wait for the process to complete. Once the process is complete get the return code in Process.exitValue().
Comments
Andy Jewell
commented May 21 '14, 3:12 p.m.
For some reason, that doesn't work. Does it work for you? I've tried Apache commons-exec, ProcessBuilder, and runTime.exec -- they all show 0 as the exit status. Yes, we have this in our junit tests and it works fine. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.