从 Mac 中删除 Java 8 JDK
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19039752/
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
Removing Java 8 JDK from Mac
提问by Rob
So I installed the beta of JDK 8 a while ago to look at some of the examples. I thought for sure by now, it's easy to change between versions.
所以我前段时间安装了 JDK 8 的 beta 来查看一些示例。我现在肯定认为,在版本之间进行更改很容易。
Doing some Play development with IntelliJ. For some reason, IntelliJ is compiling with 8 even though:
使用 IntelliJ 进行一些 Play 开发。出于某种原因,即使 IntelliJ 编译为 8:
- I have the compiler set in Preferences to use 1.6
- Supposedly it's using SBT through external build, but sbt from the command line works
- JAVA_HOME is pointing to JDK 6.
- 我在首选项中将编译器设置为使用 1.6
- 据说它是通过外部构建使用 SBT,但命令行中的 sbt 有效
- JAVA_HOME 指向 JDK 6。
If I go to the Java Preferences page, it does show 8 installed, but there is no option to uninstall it and it doesn't see any of the other versions.
如果我转到 Java 首选项页面,它确实显示已安装 8,但没有卸载它的选项,也看不到任何其他版本。
When I do which java
, it tells me /usr/bin/java
and I do /usr/bin/java -version
and it returns 1.6.
当 I do 时which java
,它告诉我/usr/bin/java
并且 I do/usr/bin/java -version
并返回 1.6。
Note: with a little fiddling, you can use IntelliJ and JDK7, see here.
注意:稍微摆弄一下,您就可以使用 IntelliJ 和 JDK7,请参见此处。
采纳答案by Samuel Alpoim
I was able to unistall jdk 8 in mavericks successfully doing the following steps:
我能够通过以下步骤成功地在小牛队中卸载 jdk 8:
Run this command to just remove the JDK
运行此命令以删除 JDK
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
Run these commands if you want to remove plugins
如果要删除插件,请运行这些命令
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/PrivilegedHelperTools/com.oracle.java.JavaUpdateHelper
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
回答by kmorris
Managing Java versions on Mac OSX is a nightmare. I recently switched over to using JDK 1.7, deleting JDK 6 from my MacBook entirely (I also had traces of JDK 5 - this laptop has been updated a few times).
在 Mac OSX 上管理 Java 版本是一场噩梦。我最近切换到使用 JDK 1.7,从我的 MacBook 中完全删除了 JDK 6(我也有 JDK 5 的痕迹——这台笔记本电脑已经更新了几次)。
Here's what I did to move to JDK 7.
这是我为迁移到 JDK 7 所做的工作。
1) download the latest from Oracle (http://www.oracle.com/technetwork/java/javase/downloads/index.html) and install it.
1) 从 Oracle ( http://www.oracle.com/technetwork/java/javase/downloads/index.html) 下载最新版本并安装。
2) Remove (using rm - if you've got backups, you can revert if you make a mistake) all the JDK6 and JRE6 files.
2)删除(使用 rm - 如果你有备份,如果你犯了错误,你可以恢复)所有的 JDK6 和 JRE6 文件。
At this stage, you should see:
在这个阶段,你应该看到:
% ls /Library/Java/JavaVirtualMachines/
jdk1.7.0_nn.jdk
(and nothing else)
(没有别的)
3) In the folder /Library/Java/Extensions/, you'll need to remove all the old jar files, the ones that correspond to other releases of Java. If you don't, you'll get the infamous message about the wrong version of tools.jar (see Builds failing after upgrading to Java7, Missing Tools.jar and bad class versions). It is not enough to rename the jar files, because Java will open every jar in that folder - I moved mine into a sub-directory. It's safe to remove them once you know everything else works.
3) 在文件夹 /Library/Java/Extensions/ 中,您需要删除所有旧的 jar 文件,这些文件对应于其他 Java 版本。如果不这样做,您将收到关于 tools.jar 版本错误的臭名昭著的消息(请参阅升级到 Java7 后构建失败、缺少 Tools.jar 和错误的类版本)。重命名 jar 文件是不够的,因为 Java 将打开该文件夹中的每个 jar - 我将我的移动到一个子目录中。一旦您知道其他一切正常,就可以安全地删除它们。
I haven't found I need to set JAVA_HOME for simple things.
我还没有发现我需要为简单的事情设置 JAVA_HOME。
Note: I just tried running IntelliJ and it will notstart unless you have Apple's JDK 6 installed (see http://youtrack.jetbrains.com/issue/IDEA-93710). Same is true for Eclipse. Netbeans works fine.
注意:我刚刚尝试运行 IntelliJ,除非您安装了 Apple 的 JDK 6,否则它不会启动(请参阅http://youtrack.jetbrains.com/issue/IDEA-93710)。Eclipse 也是如此。Netbeans 工作正常。
回答by Grégory Joseph
Use /usr/libexec/java_home
; I found these alias and function to be pretty useful in my ~/.profile
:
使用/usr/libexec/java_home
; 我发现这些别名和函数在我的~/.profile
:
alias java_ls='/usr/libexec/java_home -V 2>&1 | cut -s -d , -f 1 | cut -c 5-'
function java_use() {
export JAVA_HOME=$(/usr/libexec/java_home -v )
java -version
}
回答by Danny Shi
If you have installed jdk8 on your Mac but now you want to remove it, just run below command "sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk"
如果您已经在 Mac 上安装了 jdk8,但现在想要删除它,只需运行以下命令“sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk”
回答by Lonre Wang
Here is the official document about uninstalling the JDK.
这里是关于卸载JDK的官方文档。
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903
http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903
回答by Neal Rauhauser
This worked perfectly for me:
这对我来说非常有效:
sudo rm -rf /Library/Java/JavaVirtualMachines
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
回答by Neal Rauhauser
If you uninstall all the files but it still fails, use this line:
如果卸载所有文件但仍然失败,请使用以下行:
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk
回答by Jonny T S
You just need to use these commands
你只需要使用这些命令
sudo rm -rf /Library/Java/*
sudo rm -rf /Library/PreferencePanes/Java*
sudo rm -rf /Library/Internet\ Plug-Ins/Java*
回答by Thank you
I nuked everything Java, JDK, and oracle. I was running Java 8 on OSX El Capitan
我对 Java、JDK 和 oracle 的所有内容进行了核试验。我在 OSX El Capitan 上运行 Java 8
Other answers were missing tons of stuff. This answer covers a lot more bases.
其他答案缺少大量的东西。这个答案涵盖了更多的基础。
Good bye, shovelware.
再见,铲子。
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/LaunchAgents/com.oracle.java.Java-Updater.plist
sudo rm -rf /Library/LaunchDaemons/com.oracle.java.Helper-Tool.plist
sudo rm -rf /Library/Preferences/com.oracle.java.Helper-Tool.plist
sudo rm -rf /System/Library/Frameworks/JavaVM.framework
sudo rm -rf /usr/bin/java
sudo rm -rf /usr/bin/javac
sudo rm -rf /usr/bin/javadoc
sudo rm -rf /usr/bin/javah
sudo rm -rf /usr/bin/javap
sudo rm -rf /usr/bin/javaws
sudo rm -rf /var/db/receipts/com.oracle.jdk8u65.bom
sudo rm -rf /var/db/receipts/com.oracle.jdk8u65.plist
sudo rm -rf /var/db/receipts/com.oracle.jre.bom
sudo rm -rf /var/db/receipts/com.oracle.jre.plist
sudo rm -rf /var/root/Library/Preferences/com.oracle.javadeployment.plist
sudo rm -rf ~/Library/Preferences/com.oracle.java.JavaAppletPlugin.plist
sudo rm -rf ~/Library/Preferences/com.oracle.javadeployment.plist
sudo rm -rf ~/.oracle_jre_usage
回答by Karthik damodara
To uninstall java of any version on mac just do:
要在 mac 上卸载任何版本的 java,只需执行以下操作:
sudo rm -fr /Library/Java/JavaVirtualMachines/jdk-YOUR_ACCURATE_VERSION.jdk/
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane