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.

Qwertie
  • 886

2 Answers2

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. :)

gertvdijk
  • 67,947
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

  • 2
    -1 for messing around with symlinks yourself rather than using a tool like update-alternatives. – gertvdijk Aug 22 '14 at 08: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. – Achim Krauß Aug 28 '14 at 10:20
  • Oh I know: http://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