42

I typed:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/ jdk1.8.0/bin/java" 1

It's says alternatives --install needs link name path priority

  • 1
    What are you typing exactly? please be careful with any punctuation (e.g. dashes) and spaces – steeldriver Jul 5 '14 at 16:42
  • @steeldriver could you explain link name path priority . If there were no link like "/user/bin/java/" then will erroneous result? – Swapnil Jul 5 '14 at 16:53
  • 1
    It should create the link (and the name if there is no current java group in /etc/alternatives). AFAIK the only thing that must pre-exist is the path component i.e. /usr/lib/jvm/jdk1.8.0/bin/java - but note that (as posted in your question) you have a space in yours - hence my 1st comment. – steeldriver Jul 5 '14 at 16:58
  • @steeldriver yeah /usr/lib/jvm/bin/java/ is available . I've try sudo update-alternatives -- install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0.05/bin/java" 1 – Swapnil Jul 5 '14 at 17:22
  • 1
    Are you leaving a space between the -- and the word install? if so, don't - it needs to be --install. Also the quotes should not be necessary, just sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0.05/bin/java 1 – steeldriver Jul 5 '14 at 17:35
59

Are you leaving a space between the -- and the word install? if so, don't - it needs to be --install

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0.05/bin/java 1

The quotes should not be necessary since none of the elements have embedded spaces - although they shouldn't do any harm.

| improve this answer | |
  • 1
    Also, keep in mind that relative paths aren't accepted here, you must use the absolute path. – Bruno Finger Jul 10 '18 at 8:06
  • what is the range of priority numbers?, thanks in advance. – christianbueno.1 Sep 21 '19 at 18:47
11

The command sintax is

sudo update-alternatives --install <link> <name> <path> <priority>

if there are no space in the parameters, you don't need quotes.

In your case:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0/bin/java 1

Pay attention: did you really have a space in the path before jdk?

| improve this answer | |
3

This is beacause this command maintains symbolic links. I recommend to execute man update-alternatives to get more information about the command.

| improve this answer | |
3

Just trying to contribute with this post. I use this command, once that I know my setup correctly.

echo 1 | sudo update-alternatives --config java
| improve this answer | |

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.