在 Ubuntu Linux 中将 Java 1.6 默认设置为 1.7 以上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18474050/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set Java 1.6 default over 1.7 in Ubuntu Linux
提问by Mr Mikkél
Here is the output to some inspection that I did:
这是我所做的一些检查的输出:
$ java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
and
和
$ update-java-alternatives -l
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
and
和
$ ls /usr/lib/jvm/
default-java java-1.5.0-gcj-4.6 java-1.6.0-openjdk java-1.6.0-openjdk-amd64 java-6-openjdk java-6-openjdk-amd64 java-6-openjdk-common java-7-openjdk-amd64
With that in mind, how do I go about changing the default to 1.6 so that when I execute java -version, it tells me 1.6?
考虑到这一点,我如何将默认值更改为 1.6,以便在我执行 java -version 时,它告诉我 1.6?
Thanks!
谢谢!
采纳答案by Petr Mensik
I am on Fedora but I hope that alternatives works the same way on Ubuntu. You need to run update-alternatives --config java
(on Fedora just alternatives --config java
) to see what options you have. Then type the number of the JDK you want to use and press enter. And that's it:-)
我在 Fedora 上,但我希望替代品在 Ubuntu 上也能以同样的方式工作。您需要运行update-alternatives --config java
(仅在 Fedora 上alternatives --config java
)以查看您有哪些选项。然后键入您要使用的 JDK 的编号并按 Enter。就是这样:-)
回答by vivek
Set default java:
设置默认java:
mv /usr/bin/java /usr/bin/java_1.6
ln -s /usr/java/jdk1.7.0_55/bin/java /usr/bin/
回答by Nirbhay Rana
us below command to set the java. sudo update-alternatives --config java
我们下面的命令来设置 java.lang. 须藤更新替代品--config java
It will display the option to select you appropriate java version
它将显示选择合适的 Java 版本的选项