Just use an asynchronous action with poll: 0
:
- command: yourscript.sh async: 45 poll: 0
These options are needed to prevent ansible from killing the child processes of that task with os.killpg.
Then in yourscript.sh:
java Test & disown
disown removes the process from job table, so SIGHUP does not get sent to it. nohup does the same, but is not necessary.
Edit: Note that disown is not available in all shells (eg. dash)