Help - Search - Members - Calendar
Full Version: Help getting program to run as root in shortcut
Linuxhelp > Support > Technical Support
timo1023
I can't seem to figure out how to get my .jar program to run as root. I know root is bad, but I need to run it as root all the time. I want to create a shortcut to do this for me, but I can't figure out. I think it has something to do with sudo, but I have no idea where to begin.

Thanks.

Btw, I'm using Ubuntu (You can't log in as root, only sudo)
g33k
First open up a terminal and then log as root using this
CODE
su

Then enter the root password..and then you can run the jar files using
CODE
java -jar <my_program.jar>

If you want a shortcut i think you will need a shell script..open any text editor and then type this
CODE
#!/bin/sh
su -c "java -jar <my_program.jar>"

then save this file as myprog.sh..then link this file to /bin or /usr/bin with
CODE
su
chmod +x <path to the .sh file>
ln -s <full path to the sh file> /bin/myprog

Now you can invoke your java program using the shortcut
CODE
myprog
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.