Hi, I have a java program(GUI) with GPIO controls created in Netbeans IDE. I can run my program using “sudo java -jar path/to/my/program.jar”. I want to run the program on start up. I tried using “Startup Application Preference” but no success. Anyone can help me? Thanks in advance.
/home/pi/Desktop/dist/DPK.jar
(file path and filename)
I’ll bet your command would work in Startup Applications by just replacing sudo with gksu which is the GUI version to ask for your password to run as root.
Unfortunately, it may run a little silly because the desktop may be coming up and it WILL ask for a password.
There’s ways to reduce the strange startup it creates but eliminating the password would take some power scripting.
I've used /etc/rc.local to do things like mount network drives on login but never for an interactive GUI in a DE. I'm assuming this .jar needs to interact with the desktop. In general, system programs have a user component for the GUI.
I'll mention sudo's -S option. Feel free to research but I'd never endorse it.
You can use sudo for single commands without a password.
Have a look here and search for NOPASSWD.
After editing your sudoers file you can start your program / script from the startup applications
without to enter your password for the sudo command.
But be aware: This might be a security risk.