3

I recently installed eclipse the manual way. Extracting the file, setting up eclipse.desktop etc. It all works flawlessly. I also know it is possible to install eclipsee using sudo apt-get install eclipse-platform. If I use this method I can use the command eclipse in the terminal, and the program will start.

Now the manual way I used does not enable the eclipse-command in the terminal. Instead if I use eclipse-command it asks me to install eclipse from the Softwarecenter (sudo apt-get install eclipse-platform).

I wondered if there was some way of setting up a command like this to start eclipse? If so, can I do it for other programs like Apache-Maven mvn-command?

I don't want to use "aliases" because I cannot setup and eclipse alias, when "eclipse" is listed in the apt repository. It seems as if only if I install the eclipse from apt-get install I can start eclipse from a single command in the terminal.

I appreciate any help, and thanks in advance!

sleort
  • 438
  • Yes, it is possible. You can use an alias for that. I think that there is an answer for this in other post. I'll search for it an let you know (you can also search around similar posts) – Lucio Nov 06 '13 at 21:18
  • but this doesnt work if the program is already listed in the apt repositories. – sleort Nov 06 '13 at 21:43
  • No because you won't need it. Did I misunderstand something? – Lucio Nov 06 '13 at 21:44
  • the thing is with aliases I cannot setup my manual install to use the ´eclipse´-command. Instead I can use something like ´eclipse1´, but I'd like to "overwrite" ´eclipse´(from the apt repository, which is NOT installed on my pc). It might seem a little silly, but I like to install things manually, and I just thought if I could use the standard commands instead of remembering a lot of standardcommand-derivatives? – sleort Nov 06 '13 at 22:02
  • 2
    Are you sure that the alias doesn't work? Have you tried? – Lucio Nov 06 '13 at 22:11

2 Answers2

5

You may be totally wrong when you say: "I cannot setup an eclipse alias, when "eclipse" is listed in the apt repository". That's because the sequence adopted by the BASH shell to search for how to execute your command is as follow:

  1. Before a command is executed REDIRECTION is done. Then following sequence used by SHELL
  2. ALIASES
  3. Parameter expansion, command substitution, arithmetic expansion, and quote removal before being assigned to the variable
  4. Shell FUNCTION
  5. BUILTIN command
  6. HASH tables
  7. PATH variable
  8. If everything fails, you see command not found error message and if an appropriate packet exist in repositories, it will let you know.

Source: How BASH Shell Command Search Sequence Works.

So you can use all your aliases with confidence.

Anyway, here is a list of choices about how to "create a new terminal command" for eclipse:

  • Create a new alias:

    alias eclipse="/path/to/eclipse"
    

    Se also: How to create a permanent "alias"?

  • Create a new shell function called eclipse:

    eclipse () { /path/to/eclipse; }
    

    Add this function at the end of your ~/.bashrc file if you want to use it every time when you open the terminal.

  • Create a new bash script called eclipse:

    #!/bin/bash
    
    /path/to/eclipse
    

    Save this script in your~/bin directory and don't forget to make it executable using the following command:

    chmod +x ~/bin/eclipse
    
  • Create a symbolic link for eclipse:

    sudo ln -s /path/to/eclipse /usr/bin/eclipse
    
  • Add /path/to/eclipse to your PATH environment variable (this answer):

    PATH="/path/to/eclipse:$PATH"
    

    See also: How to add a directory to the PATH?

Now, the choice is yours!

Radu Rădeanu
  • 169,590
4

You should add the directory where eclipse is to your path:

PATH=/path/to/eclipse/bin:$PATH

Editing your .bashrc file and adding that line at the end, should solve your issue. Restarting your terminal (ie. logging out, or opening another terminal) should allow you to verify your actions:

which eclipse
/path/to/eclipse/bin/eclipse
Braiam
  • 67,791
  • 32
  • 179
  • 269