# I can't execute java program

**URL:** <https://forum.ansible.com/t/i-cant-execute-java-program/22650>\
**Category:** Ansible Project\
**Created:** [September 27, 2016, 8:07am UTC](https://forum.ansible.com/t/i-cant-execute-java-program/22650 "2016-09-27T08:07:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user94](https://avatars.discourse-cdn.com/v4/letter/u/ecd19e/32.png) [@user94](https://forum.ansible.com/u/user94)\
**Post date:** [September 27, 2016, 8:07am UTC](https://forum.ansible.com/t/i-cant-execute-java-program/22650/1 "2016-09-27T08:07:56Z")

</div>

Hi,  
May I ask for execute java program with ansible?  
I execute a java program (spring boot project, a jar package for java web site)  
ansible ofbiz1 -m shell -a “chdir=/opt/CassEC-OrderSupports nohup java -jar product.jar &”, it echo success ,but in fact,it do nothing! the java program is not been started!  
I’m very sure that I can execute nohup java -jar product.jar & in the machine directly, I can start the java program.

and I try use this command ,  
ansible ofbiz1 -m shell -a “chdir=/opt/CassEC-OrderSupports nohup /usr/java/jdk1.8.0\_74/java -jar product.jar &”,  
as I prefer the java direction, it work!

Can anybody tell me why? and how can I use java -jar direct with ansible?

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [September 28, 2016, 7:23am UTC](https://forum.ansible.com/t/i-cant-execute-java-program/22650/2 "2016-09-28T07:23:11Z")

</div>

I'd avoid nohup like the plague.

Why not just write a small upstart or systemd script and run your java  
app as a service: task?
