5

I downloaded eclipse and extracted it to /opt.

My question is how can I make it run from terminal as like other programs like javac, java. I did with update-alternatives as follows:

sudo update-alternatives --install "/usr/bin/eclipse" "eclipse" "/opt/eclipse/eclipse" 1 

I didn't get any error. I traversed and saw /usr/bin/eclipse was there, So I did:

sudo eclipse

and I got:

sudo: eclipse: command not found
  1. Is this possible to execute command eclipse and my eclipse would start?
  2. How can I make my User Program as one of the executable programs from terminal?
  3. Am I using update-alternatives for correct purpose?
  4. Any other solution?

2 Answers 2

5

Just run eclipse and it will start. There is no need to run it with sudo. The update-alternatives --install made soft link needed to launch Eclipse. That's the purpose of this tool.

However, if you install Eclipse from Software Center, it may override this link, so it is better to place it in /usr/local/bin. This directory has priority when executing commands by default.

Other solution is to manually sudo ln -s /opt/eclipse/eclipse /usr/local/bin. Notice that I'm using /usr/local prefix because it's more appropriate in this case.

UPD: It seems something wrong went while you was unpacking Eclipse. The execution bit has gone. To restore it, you need to run:

sudo chmod +x /opt/eclipse/eclipse
8
  • I did sudo ln -s /opt/eclipse/eclipse /usr/local/bin it was fine. Later I did sudo eclipse still same error & I know in this case it isn't neccessary to place it in /usr/bin or /usr/bin/local but wanted to learn. :)
    – Deepen
    Apr 28, 2014 at 7:54
  • @DpN just don't use sudo. There is no reason for it and that is what is causing the problem.
    – terdon
    Apr 28, 2014 at 9:06
  • On using only eclipse command its replying this bash: /usr/local/bin/eclipse: Permission denied
    – Deepen
    Apr 28, 2014 at 9:49
  • @DpN Use sudo chmod +x /opt/eclipse/eclipse then run eclipse.
    – Danatela
    Apr 28, 2014 at 10:27
  • /opt/eclipse/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20140116-2212/eclipse_1508.so: cannot open shared object file: Permission denied
    – Deepen
    Apr 28, 2014 at 10:28
1

For those looking to put an executable to /usr/bin, as the tittle.

sudo cp ./TheProgram /usr/bin

So you can now launch TheProgram from anywhere by just typing:

TheProgram

This is okay if your executable can run static with no dependencies.

We can use Shebang scripts the same way, this does not have to be a binary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .