无法在 Ubuntu 16.04 中删除 java
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45572573/
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
Can't remove java in Ubuntu 16.04
提问by Charles Zha
This post can be move to Linuxor Super Userblocks.
这篇文章可以移到Linux或超级用户块。
I want to install java 8 in my virtualbox ubuntu16.04, but whenever I check version using -version, it shows
我想在我的虚拟机 ubuntu16.04 中安装 java 8,但是每当我使用 -version 检查版本时,它都会显示
> java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
To uninstall and reinstall java, I searched and find the following resources:
为了卸载和重新安装java,我搜索并找到了以下资源:
However there is no java7 listed.
但是没有列出java7。
sudo dpkg --list | grep -i jdk
ii oracle-java8-installer 8u144-1~webupd8~0 all Oracle Java(TM) Development Kit (JDK) 8
ii oracle-java8-set-default 8u144-1~webupd8~0 all Set Oracle JDK 8 as default Java
When I check Java version, it still shows java 1.7.0_05n. The same for javac.
当我检查 Java 版本时,它仍然显示 java 1.7.0_05n。javac 也是一样。
>javac -version
javac 1.7.0_05
Any idea what's happening?
知道发生了什么吗?
It turns out that the package I used was automatically changing $JAVA_HOME into a Java package in its directory.
结果是我使用的包自动将 $JAVA_HOME 变成了其目录中的 Java 包。
回答by Makoto
You've got Oracle Java installed, not OpenJDK. If you want to uninstall it, you can do this:
您已经安装了 Oracle Java,而不是 OpenJDK。如果你想卸载它,你可以这样做:
sudo apt-get remove oracle-java7-*
In effect, you were telling apt to install something that was never installed on your machine.
实际上,您是在告诉 apt 安装一些从未安装在您的机器上的东西。
回答by Charles Zha
The thing I actually needed is to change the JAVA_HOME in the environment. For some reason sudo update-alternatives --config java
doesn't really help choose the java version.
我真正需要的是改变环境中的 JAVA_HOME 。出于某种原因,sudo update-alternatives --config java
并没有真正帮助选择 Java 版本。
Here is what I did to solve the issue: https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
这是我为解决该问题所做的工作:https: //www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
xxx@xxx-VirtualBox:/usr/lib/jvm$ sudo nano /etc/environment
(In which we add JAVA_HOME = "/path/to/java", for me is JAVA_HOME="/usr/lib/jvm/default-java"
)
(我们在其中添加JAVA_HOME = "/path/to/java",对我来说是JAVA_HOME="/usr/lib/jvm/default-java"
)
$ java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b06)
Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)
$ source /etc/environment
$ java -version
openjdk version "1.8.0_131"
OpenJDK Runtime Environment (build 1.8.0_131-8u131-b11-2ubuntu1.16.04.3-b11)
OpenJDK 64-Bit Server VM (build 25.131-b11, mixed mode)
Thanks SharpLu and Makoto for the help.
感谢 SharpLu 和 Makoto 的帮助。