Here is how I got it to work on my VPS running Linux and its running as a service. If for any reason the VPS reboots, then my B4J app will start automatically.
I used SFTP and copied my B4J app to /opt/CloudServer/CloudServer.jar
I then created a start-up script. This script will run as soon as the server boots up.
sudo nano /etc/systemd/system/CloudServer.service
[Unit]
Description=CloudServer Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /opt/CloudServer/CloudServer.jar
StandardOutput=syslog
StandardError=syslog
SuccessExitStatus=143
Restart=on-abort
[Install]
WantedBy=multi-user.target
sudo systemctl enable CloudServer.service
This will enable the service.
sudo systemctl start CloudServer.service
This will start the service.
systemctl status CloudServer.service
This will check the service to see if it's running.
Hope this helps.