Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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!

share|improve this question
    
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 6 '13 at 21:18
    
Here it is :) –  Lucio Nov 6 '13 at 21:23
    
but this doesnt work if the program is already listed in the apt repositories. –  sleort Nov 6 '13 at 21:43
    
No because you won't need it. Did I misunderstand something? –  Lucio Nov 6 '13 at 21:44
2  
Are you sure that the alias doesn't work? Have you tried? –  Lucio Nov 6 '13 at 22:11

2 Answers 2

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 my path?

Now, the choice is yours!

share|improve this answer

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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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