2

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!

  • @vanadium Yes! I think i need to run netbeans in root else it displays error https://imgur.com/a/6u0uz1r. This can be over-comed by changing netbeans directory. but I think i can learn something new from this question. changing netbeans directory is is just passable – Khushit shah Mar 24 '19 at 11:51
  • updated image link : https://imgur.com/a/kj648EH – Khushit shah Mar 24 '19 at 11:59
  • Check the folder mentioned in the error message: see that it exists and has the correct owner and permissions set. It is very bad practice to launch a program as root in order to mask configuration errors. – vanadium Mar 24 '19 at 12:01
  • @vanadium Well changing the userdir and chachedir of netbeans solves the problem. but just sake of curiousness It would be great to known solution of the question! – Khushit shah Mar 24 '19 at 12:16