After downloading netbeans 10.0 I taught of creating a desktop file to launch it, So, I don't have to run sudo /home/abc/Downloads/netbeans/bin/netbeans
every time.
I created small script to launch netbeans in admin priviliges.
#!/bin/sh
cd /home/abc/Downloads/netbeans/bin/
echo "password" | sudo -S ./netbeans
I put this file to /usr/bin/
and
created netbeans.desktop file as follows
[Desktop Entry]
Version=1.0
Type=Application
Terminal=False
Exec=/usr/bin/netbeans
Name=Netbeans
Comment=Java IDE
Icon=/home/abc/Downloads/netbeans/nb/netbeans.icns
by typing
netbeans
in terminal it opens netbeans in admin privileges.
But clicking the desktop file or shell file doesn't respond anything
Sorry if it is silly I am a Newbie.
EDIT
Tried everything stated here => How do I run a 'sudo' command inside a script? but nothing worked.
As @dessert suggested to use pkexec
. It works but gives another problem.
/home/abc/Downloads/netbeans/platform/lib/nbexec: WARNING: environment variable DISPLAY is not set
I think netbeans needs terminal to run. and so I tried xdf-open
and gksu
but non of them worked.
Please help!
pkexec
to get a GUI password prompt (Exec=pkexec /usr/bin/netbeans
), see How can I run an application with a GUI as admin from a non-admin user session?. – dessert Mar 24 '19 at 11:11