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. :)
Related videos on Youtube
![Qwertie](https://i.stack.imgur.com/DUiG3.jpg?s=256&g=1)
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, 2022Comments
-
Qwertie almost 2 years
I was setting up android studio and got this
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 over 10 yearsDid you try installing Oracle's java? I think I had a similar problem with android studio
-
Qwertie over 10 years@AmithKK I did download it but I haven't installed it yet. I will try that now
-
Qwertie over 10 yearsI have extracted the Oracle JDK but how do I install it?
-
Avinash Raj over 10 yearssee this askubuntu.com/questions/25961/…
-
Braiam over 10 years@qwertyk31 did you installed any java version (preferable the OpenJDK)?
-
Qwertie over 10 years@Braiam I have OpenJDK now
-
Braiam over 10 yearsNothing better?
-
Braiam over 10 yearsIf something changed? Or still the same error?
-
Qwertie over 10 yearsI have always had OpenJDK installed
-
-
gertvdijk almost 10 years-1 for messing around with symlinks yourself rather than using a tool like
update-alternatives
. -
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 almost 10 yearsOh 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).