How to Daemonize a Java Program?

I have a Java program that I’d like to daemonize on a linux system.
In other words, I want to start running it in a shell and have it continue running after I’ve logged out.
Even After I reboot my system, my java program should be up and running like any other daemon service (sshd etc..)
I also want to be able to stop the program cleanly.

What’s your preferred method to daemonize a Java program on a Linux system?

I have Java Archive (vm.jar) , I want to run this Jar as an UNIX Service. Here are steps I followed to achieve that

  1. Install daemon tools from the URL  and follow the instruction mentioned there,for any issues please try instructions  error.h
  2. Create a file at /etc/init/svscan.conf and add the below lines.(only required for cent-os-6.7)

start on runlevel [12345]
stop on runlevel [^12345]
exec /command/svscanboot

3. Create a new script named run inside /service/vm/ folder and add the below lines.

echo starting VM
exec java -jar /root/learning-/daemon-java/vm.jar

replace the Jar with your own Jar file. or any java class file.

4. Reboot the system

5. svstat /service/vm should be up and running now !.

6. svc -d /service/vm should bring vm down now !.

7. svc -u /service/vm should bring vm up now !.