eclipse 如何在 macOS Sierra 上卸载 Java 9
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47897097/
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
How to uninstall Java 9 on macOS Sierra
提问by Espin
I'm having trouble removing Java 9
from my macOS Sierra
system.
我在Java 9
从macOS Sierra
系统中删除时遇到问题。
I accidentally installed Java 9
, instead of Java 8
, so now all my Eclipse
projects give me these warnings: Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
我不小心安装了Java 9
, 而不是Java 8
,所以现在我所有的Eclipse
项目都给我这些警告:Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
I have used the following guide, but it did not work. Here is my command output when running java -version
from the command line:
我使用了以下指南,但没有用。这是我从命令行运行时的命令输出java -version
:
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
采纳答案by Espin
After viewing which Java Virtual Machines I had on my computer using the following command:
使用以下命令查看我的计算机上有哪些 Java 虚拟机后:
ls /Library/Java/JavaVirtualMachines
ls /Library/Java/JavaVirtualMachines
I realized no additional JDK's would appear after using the Java 8 installer (besides Java 9). When doing further research, it turns out I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.
我意识到在使用 Java 8 安装程序(除了 Java 9)之后不会出现额外的 JDK。在做进一步的研究时,结果证明我安装了另一个版本,它不是 SE 开发工具包,它只是在网络浏览器中工作,而不是在终端上工作。
For anyone having the same issue, make sure you use the Java SE Development Kit 8.
对于遇到相同问题的任何人,请确保使用Java SE Development Kit 8。
回答by Stephen Ga
for macOS high sierra removing java 9:
对于 macOS high sierra 删除 java 9:
delete the java folder you find in the dir shown to you after executing:
执行后删除您在显示给您的目录中找到的 java 文件夹:
/usr/libexec/java_home -V
/usr/libexec/java_home -V
use "Go to" in finder and copy and paste the dir to get there
在finder中使用“Go to”并复制并粘贴目录以到达那里
回答by Rahul Ghadge
There are two commands which are very simple and useful. If you want to keep multiple versions simply set JAVA_HOME to version you want to use.
有两个命令非常简单和有用。如果您想保留多个版本,只需将 JAVA_HOME 设置为您要使用的版本。
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(version you want to use).jdk/Contents/Home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(你要使用的版本).jdk/Contents/Home
Example--> export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
示例--> 导出 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Else in addition to above command remove/uninstall additional jdk version from your system with below command.
除了上述命令之外,使用以下命令从您的系统中删除/卸载其他 jdk 版本。
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(version you want to remove).jdk/
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(要删除的版本).jdk/
Example --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/
示例 --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/
Please refer below github link for additional details --> https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
有关更多详细信息,请参阅下面的 github 链接 --> https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
Thanks
谢谢
回答by Kevin Hooke
On MacOS you can list what JDKs you have installed and where they are installed to with:
在 MacOS 上,您可以列出已安装的 JDK 及其安装位置:
/usr/libexec/java_home -V
If you want to select one of the installed JDKs to be used as default, you can do:
如果要选择已安装的 JDK 之一作为默认值,可以执行以下操作:
/usr/libexec/java_home -v 1.8
Verify which is now default with java -version.
使用 java -version 验证哪个现在是默认值。
You can manually add the location of other installed JREs in Eclipse via Preferences / Java / Installed JREs , press Add, and then point it to one of the locations should with the -V option above. You can then check it to select which is default for your projects.
您可以通过 Preferences / Java / Installed JREs 在 Eclipse 中手动添加其他已安装 JRE 的位置,按添加,然后将其指向应使用上面的 -V 选项的位置之一。然后,您可以选中它以选择项目的默认设置。
回答by douglas
I believe the problem is navigating to the correct directory... Once you are where you are supposed to be you can run the sudo
commands to remove whichever versions of java you want to remove.
我相信问题是导航到正确的目录......一旦你到了你应该去的地方,你就可以运行sudo
命令来删除你想要删除的任何版本的java。
First, run the command in the terminal to determine which version of Java you are running,
首先,在终端中运行命令以确定您正在运行的 Java 版本,
java -version
then you can navigate to pesky version of java that you intend to delete by using the following command:
然后您可以使用以下命令导航到您打算删除的讨厌的 Java 版本:
cd /Library/Java/JavaVirtualMachines
then once you see are in the JavaVirtualMachines path, type in ls to see what versions of Java you have installed,
然后一旦你看到在 JavaVirtualMachines 路径中,输入 ls 来查看你安装的 Java 版本,
ls
and finally when you know which version or versions of Java you want to uninstall:
最后,当您知道要卸载的 Java 版本时:
sudo rm -rf jdk-10.0.1.jdk #or whichever version you want to delete
回答by ParthS007
Uninstall Oracle Java using the Terminal:
使用终端卸载 Oracle Java:
Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool. Remove one directory and one file (a symlink), as follows:
注意:要卸载 Java,您必须具有管理员权限并以 root 身份或使用 sudo 工具执行 remove 命令。删除一个目录和一个文件(一个符号链接),如下:
Click on the Finder icon located in your dock
Click on the Utilities folder
Double-click on the Terminal icon
In the Terminal window Copy and Paste the commands below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
不要试图通过从 /usr/bin 中删除 Java 工具来卸载 Java。此目录是系统软件的一部分,Apple 将在您下次执行操作系统更新时重置任何更改。
Source:https://www.java.com/en/
回答by Ele
I know that you've asked about how to uninstall the java version. But, I think it's important how to manage your Java version in a very good way.
我知道你问过如何卸载 java 版本。但是,我认为如何以一种非常好的方式管理您的 Java 版本很重要。
For me, the best way is using SDKMan, a very nice tool for managing you Development tools like Java.
对我来说,最好的方法是使用 SDKMan,这是一个非常好的工具,用于管理 Java 等开发工具。
Here you can learn more about it:http://sdkman.io/
您可以在这里了解更多信息:http : //sdkman.io/
You can install your Java version as follow:
您可以按如下方式安装 Java 版本:
$ sdk install java
$ sdk install java
You can install others tools like Scala:
您可以安装其他工具,例如 Scala:
$ sdk install scala 2.12.1
$ sdk install scala 2.12.1
Uninstall your tools very easy:
卸载您的工具非常简单:
$ sdk uninstall java 9
$ sdk uninstall java 9
And so on. Hope this helps you in future installation of your development tools.
等等。希望这有助于您将来安装开发工具。