2

I've been having trouble with the Netbeans desktop file generated by the netbeans install script. The file in question, as found in the /usr/share/applications folder, is very simple:

[Desktop Entry]
Encoding=UTF-8
Name=NetBeans IDE 8.0
Comment=The Smarter Way to Code
Exec=/bin/sh "/usr/local/netbeans-8.0/bin/netbeans"
Icon=/usr/local/netbeans-8.0/nb/netbeans.png
Categories=Application;Development;Java;IDE
Version=1.0
Type=Application
Terminal=0

The netbeans application itself runs perfectly fine if I run it from a terminal using /usr/local/netbeans-8.0/bin/netbeans. Am I missing something here? I can't figure out how to get the error output if I run it by double-click or from the launcher. There are no errors on the terminal run. Any ideas?

Edit: The netbeans file is executable.

1

try without /bin/sh

Exec=/usr/local/netbeans-8.0/bin/netbeans
  • I had tried that initially. I've solved the problem now, though, so it's cool. Sorry to waste your time and thanks! – Aargonian Aug 27 '15 at 1:48
  • /bin/sh is indeed redundant, but it should not cause any problem – kos Aug 27 '15 at 5:00
1

I figured out the issue by looking through syslog. I probably should have done that to begin with, but I'm still a Linux noob. Sorry if I wasted anyone's time!

Apparently, Netbeans was failing to pick up a tool agent. Specifically, the instrumentation tool Jayatanaag.jar. For some reason, this didn't cause a fail state when starting directly from a terminal, but caused fail only when running from the .desktop file. To fix this error, I uninstalled and reinstalled jayatana:

sudo apt-get purge jayatana
sudo apt-get install jayatana

This fixed the issue immediately.

1

First an explanation, thank you @kos

By using an Exec= line such as

Exec=/usr/local/netbeans-8.0/bin/netbeans

netbeans is executed in sh already, because the Exec= lines in desktop files are executed as commands in sh, not in bash or else. So

Exec=/bin/sh -c "/usr/local/netbeans-8.0/bin/netbeans" 

spawns an excessive sh instance. Just

Exec=/usr/local/netbeans-8.0/bin/netbeans

will run netbeans in sh


If you really need for some reasons sh, than your Exec= property is wrong.

Here is an example with Eclipse, an other Java based IDE

% sh "/opt/eclipse/eclipse"
/opt/eclipse/eclipse: 1: /opt/eclipse/eclipse: Syntax error: "(" unexpected

To start a command with sh you need the -c switch:

Exec=/bin/sh -c "/usr/local/netbeans-8.0/bin/netbeans"

-c string
    If the -c option is present, then commands are read fromstring.
    If there are arguments after the string, they are assigned to the positional
    parameters, starting with $0.
  • The Exec= line is always run in a sh instance, so /usr/local/netbeans-8.0/bin/netbeans will be executed in sh already ;) – kos Aug 27 '15 at 5:05
  • @kos yes, I know, therefore I wrote, "If you really need..." :) – A.B. Aug 27 '15 at 5:06
  • What I meant is that by using an Exec= line such as Exec=/usr/local/netbeans-8.0/bin/netbeans, netbeans is executed in sh already, because the Exec= lines in desktop files are executed as commands in sh, not in bash or else. So Exec=/bin/sh -c "/usr/local/netbeans-8.0/bin/netbeans" spawns an excessive sh instance. Just Exec=/usr/local/netbeans-8.0/bin/netbeans will run netbeans in sh – kos Aug 27 '15 at 5:12
  • @kos yes, you're right, but some installers create an Exec property like this and it's good to know, where the problem is. – A.B. Aug 27 '15 at 5:14
  • @kos updated my answer – A.B. Aug 27 '15 at 5:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.