init script for deployment on linux machine

I have a web application which i start by the command :
java -jar start.jar jetty.http.port=8888 inside the directory /home/robinsu/tools/jetty
I need to build an initscript for this so that when the machine restarts my program is always running.
Please help me in building or guiding to build this initscript and where to place it ?

Rohit BajajAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Build process is just typing.
Press A on text editor and A appears in text file.
Jan SpringerCommented:
What is the path of java-jar and which linux distribution and version?
Rohit BajajAuthor Commented:
i am running the command inside /root/jetty
This is CentOS 7 i have setup a virtualBox
Jan SpringerCommented:
Sorry forgot to ask, what user will this service run under?
Jan SpringerCommented:
Change the "user=jetty" to the actual username.

vi /usr/lib/systemd/system/jetty-http.service

In the file:

Description=jetty http server

ExecStart=/root/jetty/java -jar start.jar jetty.http.port=8888


Enable it:

sudo systemctl enable jetty-http.service

Start it:

# sudo systemctl start jetty-http

Check the status:

# sudo systemtcl status jetty-httpjetty-http.service

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.