我正在设置 android studio 并得到这个
所以我按照答案这里并使用
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
但这给了我update-alternatives: error: alternative /usr/local/java/jdk1.7.0_17/jre/bin/java for java not registered; not setting
我该如何修复这个问题并让 android studio 正常工作?我已经安装了 openJDK。
答案1
很可能确切的 1.7.17 版本现在不同了,并且jdk1.7.0_17
不存在,因此请使用交互式命令来更改java
或javaws
替代。
$ 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
这样犯错误的可能性就小多了。:)
答案2
这也许对某些人有帮助:我遇到了一些问题。我通过将符号链接 /etc/alternatives/java 从 openJDK 更改为 Oracle JDK(您必须先安装它)来修复它。要安装 Oracle JDK,我使用了以下说明: http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html