2

I was setting up android studio and got this

enter image description here

So I followed the answer here and used

sudo update-alternatives --set java /usr/local/java/jdk1.7.0_17/jre/bin/java

sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_17/jre/bin/javaws

But this gave me update-alternatives: error: alternative /usr/local/java/jdk1.7.0_17/jre/bin/java for java not registered; not setting

How can I fix this and get android studio working? I am have openJDK installed.

10
  • Did you try installing Oracle's java? I think I had a similar problem with android studio
    – Amith KK
    Dec 10 '13 at 5:18
  • @AmithKK I did download it but I haven't installed it yet. I will try that now
    – Qwertie
    Dec 10 '13 at 5:21
  • I have extracted the Oracle JDK but how do I install it?
    – Qwertie
    Dec 10 '13 at 5:26
  • see this askubuntu.com/questions/25961/… Dec 10 '13 at 5:37
  • @qwertyk31 did you installed any java version (preferable the OpenJDK)?
    – Braiam
    Dec 10 '13 at 11:41
1

Most likely the exact 1.7.17 version is different now and the jdk1.7.0_17 does not exists, so use the interactive command to change the java or javaws alternative.

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      auto mode
* 1            /usr/lib/jvm/j2re1.7-oracle/bin/java             316       manual mode
  2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java   1061      manual mode
Press enter to keep the current choice[*], or type selection number: 1

$ sudo update-alternatives --config javaws
There are 3 choices for the alternative javaws (providing /usr/bin/javaws).
  Selection    Path                                              Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws   1071      auto mode
  1            /usr/lib/jvm/j2re1.7-oracle/bin/javaws             316       manual mode
  2            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws   1061      manual mode
  3            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/javaws   1071      manual mode
Press enter to keep the current choice[*], or type selection number: 1

It's a lot less likely to make mistakes with this. :)

0

May be this can hepls to somebody: I had some problem. And i fix it changing symlink /etc/alternatives/java from openJDK to Oracle JDK (you must install it previous). To install Oracle JDK i used this instructions: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

3
  • 2
    -1 for messing around with symlinks yourself rather than using a tool like update-alternatives.
    – gertvdijk
    Aug 22 '14 at 8:52
  • @gertvdijk What do u think this tool does? And what kind of messing? It's exactly same and tool will work fine with this alias. Aug 28 '14 at 10:20
  • Oh I know: askubuntu.com/a/233192/88802 But as I explained in my answer in this question, it's a lot less likely to make errors with using a tool to select the right path and it adjusts to the situation of the user (e.g. other versions).
    – gertvdijk
    Aug 28 '14 at 10:42

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.