Setup JDK for android studio

5,752

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

Share:
5,752

Related videos on Youtube

Qwertie
Author by

Qwertie

profile for qwertie on Stack Exchange, a network of free, community-driven Q&A sites http://stackexchange.com/users/flair/3015926.png?theme=dark Github: https://github.com/Qwertie-

Updated on September 18, 2022

Comments

  • Qwertie
    Qwertie almost 2 years

    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.

    • Amith KK
      Amith KK over 10 years
      Did you try installing Oracle's java? I think I had a similar problem with android studio
    • Qwertie
      Qwertie over 10 years
      @AmithKK I did download it but I haven't installed it yet. I will try that now
    • Qwertie
      Qwertie over 10 years
      I have extracted the Oracle JDK but how do I install it?
    • Avinash Raj
      Avinash Raj over 10 years
    • Braiam
      Braiam over 10 years
      @qwertyk31 did you installed any java version (preferable the OpenJDK)?
    • Qwertie
      Qwertie over 10 years
      @Braiam I have OpenJDK now
    • Braiam
      Braiam over 10 years
      Nothing better?
    • Braiam
      Braiam over 10 years
      If something changed? Or still the same error?
    • Qwertie
      Qwertie over 10 years
      I have always had OpenJDK installed
  • gertvdijk
    gertvdijk almost 10 years
    -1 for messing around with symlinks yourself rather than using a tool like update-alternatives.
  • Achim Krauß
    Achim Krauß almost 10 years
    @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.
  • gertvdijk
    gertvdijk almost 10 years
    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).