Why "java -version" command output was placed in stderr and not in stdout using win_command.

Hi, I was new on Ansible and testing some functionalities with Windows hosts.

Task:

  • name: Check if Java is installed
    win_command: java -version
    register: java_result

  • name: Print Java_result
    debug:
    msg: “{{ java_result }}”

Output:

Hi, I was wondering why my output was placed in stderr.
I was expecting the output will be in stdout since the command was successful and there was installed java in my host.

Can someone give me their opinion on this?
Thank you very much.

That’s just what java does https://stackoverflow.com/questions/13483443/why-does-java-version-go-to-stderr. Having values in stderr does not mean there was a failure, just that the program sent data to that stream.

Thanks

Jordan

thank you very much for the input Jordan. :slight_smile:
I will try different workaround to catch this.