Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link
You can use ProcessBuilder and wait for the process to complete. Once the process is complete get the return code in Process.exitValue().

0 votes

Comments

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

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019
× 169

Question asked: May 20 '14, 12:16 p.m.

Question was seen: 5,092 times

Last updated: May 21 '14, 10:46 p.m.

Confirmation Cancel Confirm