Setup jar to run as service on Ubuntu

Hello there,

Now I have a jar application on my Ubuntu server and is located in /home/steve/deployment/bear.server-1.0-SNAPSHOT-fat.jar and everytime i want to run my application I need to run this cmd
 java -jar bear.server-1.0-SNAPSHOT-fat.jar -conf config.json

Open in new window

. I want to know how I can run this cmd with a shotcut for e.g. run myapp. Please help!!

cheers
Zolf
zolfAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Can you please tell me how to setup with reference to my jar file location which is in my home directory
The answer to that is - not easily. It would depend on the context. If you'd like to try it the 'proper' (but initially harder) way, then you need to study something like https://wiki.archlinux.org/index.php/Systemd

I would imagine the Tanukisoft wrapper would be easier. If it's well maintained, it will do the above for you
I'm also imagining that the service is network-oriented - is that the case?
0
 
CEHJCommented:
What does bear.server-1.0-SNAPSHOT-fat.jar do? Tanukisoft probably still make their service wrapper. Whether it's been updated to cope with systemd is another issue. If it hasn't, you can write your own systemd service
1
 
David FavorConnect With a Mentor Linux/LXD/WordPress/Hosting SavantCommented:
Be sure you make all your files absolute paths, or likely you'll have no end of troubles. This includes both your .jar + .conf file.

In your system wide or user shell startup file, you can add...

alias mycmd=" java -jar bear.server-1.0-SNAPSHOT-fat.jar -conf config.json"

Open in new window


Or you can take CEHJ's suggestion + turn the above into a systemd service, so then you'd use something like...

service mycmd start

Open in new window


Where your mycmd service implemented parts of service management you require.
0
 
zolfAuthor Commented:
Thanks for all your comments.

David

In your system wide or user shell startup file, you can add...
Can you please elaborate more, I am new to ubuntu world.

CEHJ
What does bear.server-1.0-SNAPSHOT-fat.jar do?
It runs my server side application.

If it hasn't, you can write your own systemd service
Can you please tell me how to setup with reference to my jar file location which is in my home directory
0
 
zolfAuthor Commented:
cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.