I have .jar file that I would like to run when the default user logs in. The .jar contains battery simulator that is for my energy management system. I have to run it with sudo so it can open ports for modbus communication. Also it requires GUI to run so it can't be run in a headless mode. I wrote a following .sh script to make run it:
#!/bin/bash
cd /usr/BatterySim+Demo/
export DISPLAY=:0.0
sudo java -jar BatterySim.jar
I made this script executable and when I right click on it and choose Run as a Program, it opens a terminal window and runs my app after providing root password. So far I tried:
- adding it to cron(@reboot root /usr/BatterySim+Demo/BatSim.sh)
- adding as service wrapper to systemctl
- adding it to Startup Applications Preferences
systemctl service wrapper code:
[Unit]
Description=BMZ battery simulator Service
[Service]
Type=notify
ExecStart=/bin/bash -c "/usr/BatterySim+Demo/BatSim.sh"
#StandardOutput=null
Restart=on-failure
Increase the default a bit in order to allow many simultaneous
files to be monitored, we might need a lot of fds.
[Install]
WantedBy=multi-user.target
nothing worked. Do you have any other ideas that I could try?