title: Unable to run java jar command on target machine in Ansible
body: <p>I am trying to run the following command:</p>
  
  <pre><code>java -jar jar-from-application.jar --file myown.properties
  </code></pre>
  
  <p>Couple of problems I faced earlier while trying to run this on target machine. Tomcat needs to be running and a war file needs to be deployed completely before I run the above command. This is what I did to insure that pre conditions are met. For Tomcat:</p>
  
  <pre><code>nohup startup.sh
  </code></pre>
  
  <p>and then check for deployed file bu using curl to check for status 200:</p>
  
  <pre><code>- name: Check if URL is available
    shell: curl --head --silent http://target-mchine:8080/restoftheurl
    register: result
    until: result.stdout.find("200 OK") != -1
    retries: 12
    delay: 10
  </code></pre>
  
  <p>It does above two steps correctly but when the next task is to run the </p>
  
  <pre><code>java -jar jar-from-application.jar --file myown.properties
  </code></pre>
  
  <p>it for some reason says that it cannot read the properties file. However, if I run the same jar command on the remote machine locally, then it works perfectly. I even added some wait time after successful execution of curl command, just in case, but it doesn't make any difference. I tried doing the following too:</p>
  
  <pre><code>nohup java -jar jar-from-application.jar --file myown.properties
  </code></pre>
  
  <p>as it was suggested online but that didn't make any difference either. Any suggestions will be appreciated. Thank You.</p>