# How to execute a backend java program?

**URL:** <https://forum.ansible.com/t/how-to-execute-a-backend-java-program/22593>\
**Category:** Ansible Project\
**Created:** [September 20, 2016, 12:45pm UTC](https://forum.ansible.com/t/how-to-execute-a-backend-java-program/22593 "2016-09-20T12:45:30Z")\
**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 20, 2016, 12:45pm UTC](https://forum.ansible.com/t/how-to-execute-a-backend-java-program/22593/1 "2016-09-20T12:45:30Z")

</div>

Hi,  
I use ansible 2.0.0. and I want start a java web program which use spring boot and compile as a jar file, but it always don’t work.  
I can execute “nohup java -jar xxx.jar &” on the target machine (the target machine is centos 7)，but when I execute through ansible, it don’t work.  
my playbook is

`

- hosts: testservers  
remote\_user: root  
tasks:
- name: start product  
shell: chdir=/app nohup java -jar /app/product.jar &

`

I think all the method I can , for example, make a .sh file in the target machine, the sh file is

`

#!/bin/bash  
java -jar /app/product.jar \> /dev/null 2\>&1

`  
and I execute the sh file , it can start .  
and the playbook is

`  
shell: chdir=/app nohup ./startproduct.sh &

`  
and I execute the playbook,  
the product.jar can not be started yet.

and then I add it to service, the file is

`

#!/bin/bash

---

<div class="post-metadata">

**Author:** ![Alexander\_Taran](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@Alexander\_Taran](https://forum.ansible.com/u/Alexander_Taran)\
**Post date:** [January 3, 2017, 5:49pm UTC](https://forum.ansible.com/t/how-to-execute-a-backend-java-program/22593/2 "2017-01-03T17:49:12Z")

</div>

Hello, !  
(Sorry can’t spell your name).

Try this working example:

`

- name: Start jenkins  
remote\_user: “{{jenkins\_owner\_user}}”  
shell: cd {{jenkins\_home\_path\_bin}}/ && nohup java -Djenkins.install.runSetupWizard=false -Dhudson.diyChunking=false -DJENKINS\_HOME={{jenkins\_home\_path\_data}} -jar ./jenkins.war --httpPort={{jenkins\_port}} &  
async: 45  
poll: 0

`
