Thanks for posting your solution and script.
I did little modification to your script! JDownloader creates its own PIDfile because PID can change over time. Also increased sleeps because start/stop might take some time. Also piped stdout and stderr to /dev/null