You could try using systemd which is a Linux service manager. You can use it to run your service in the background.
To do that you need to first create a unit file that describes how systemd should manage your service (more info here).
sudo vim /etc/systemd/system/your-application.service
Your file might look something like this
[Unit] Description=Java Application as a Service [Service] User=ec2-user #change this directory into your workspace #mkdir workspace WorkingDirectory=/home/ec2-user/workspace #path to the executable bash script which executes the jar file ExecStart=/bin/bash /home/ec2-user/workspace/your-script.sh SuccessExitStatus=143 TimeoutStopSec=10 Restart=on-failure RestartSec=5 [Install] WantedBy=multi-user.target
Then in your home directory /home/ec2-user/workspace you can create the bash script that will run your java application.
sudo nano your-script.sh
Your script might look like this
#!/bin/sh java -jar your-application.jar
All you need to do then is start the service with the command
sudo systemctl enable your-application.service sudo systemctl start your-application.service