How do I run NetBeans from the terminal?

I have installed a JDK + NetBeans bundle from the downloaded .sh file.

Now I have the NetBeans shortcut on my desktop but I can't run NetBeans from the terminal.

When I run:

sudo dpkg --get-selections

NetBeans is not on the list and also I can't find it in the Ubuntu Software Center.

  • How do I run it from the terminal and how do I find it in the system?

  • When I installed Emacs using apt-get it appeared in the main menu and I could launch it from the terminal straight away. How do these two installations differ?


Solution 1:

Assuming you downloaded the 7.4 version

If you installed netbeans from .sh installer using sudo then the default command to run netbeans is :

/bin/sh "/usr/local/netbeans-7.4/bin/netbeans"

if you installed netbeans without sudo then the default command is :

~/netbeans-7.4/bin/netbeans

Solution 2:

dpkg is a debian package manager, since you have installed Nebeans by a (presumably local) script, it will not be listed in dpkg -l.

Retrieve an application's command from it's desktop file:

When you have an application installed of which you don't know the command, but you do have a desktop file, you can read it from the desktop file's content. The link you have on your desktop is a desktop file. Look for a line, starting with "Exec=". What comes after that string is the command you are looking for.

Make the application available in Dash:

Normally, applications install a desktop file in /usr/share/applications (like emacs does). If a desktop file is located in either that location or in ~/.local/share/applications, it appears in Dash automatically, so if you copy the desktop file into ~/.local/share/applications, it will appear in Dash after next log in.

Open an application by (only) it's binary file name (or not):

Netbeans did not open on the command netbeans because the shell does not know the path to your binary file. If binary files are located in /usr/bin (the default path to application's binary files) they will open right away, without the path-prefix. That is the case for example with emacs.

If an application does not install its binary file in /usr/bin, there are three possibilities; either the application's desktop file's execute line includes the path to the file, as you can see for example in the execute line of the file-explorer indicator's desktop file: /opt/indicator-file-explorer/bin/indicator-file-explorer, or the path to the binary file is added to $PATH (/etc/environment), so the shell will search for binary files in that directory too, or the application installs a link to the binary file in /usr/bin. All three options do occur, no matter the way an application is installed.

If you installed your application locally, it would be a bad idea to (try to-) create a link to the application's binary file from a global directory, such as /usr/bin; other users would be stuck with a dead link, because they have no valid permissions in your home directory. Therefore, the easyest way is to create a local bin directory (~/bin) and create a link to the local binary file from that directory (ln -sf). That way you can run your locally installed Netbeans by the single command netbeans.

Solution 3:

Don't know if this might help but what works for me is assuming you are the the current home directory of your user

./netbeans-8.0.2/bin/netbeans

I installed netbeans by downloading the sh installer from their website. Just curious on how to run netbeans via terminal and this worked for me.