Apple提供了一个自动Java安装程序,但没有提供卸载程序,因此一旦安装Java,您将无法删除Java,而无需使用自行承担风险的方法。
话虽如此,这是如何从终端会话和使用文本编辑器中摆脱Java的方法:
sudo rm -rf /System/Library/Java/JavaVirtualMachines/
sudo rm -rf /Library/Java/JavaVirtualMachines/*.jdk
sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefpane
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaEssentials.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaEssentials.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaForMacOSX107.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaForMacOSX107.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaMDNS.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaMDNS.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaSecurity.bom
sudo rm -rf /private/var/db/receipts/com.apple.pkg.JavaSecurity.plist
此时,您需要编辑安装历史记录以删除安装Java的证据。我建议先备份文件。如果您希望使用其他文本编辑器,请随时使用它,但不要使用在文本文件中放置格式代码的文字处理器。
sudo cp /Library/Receipts/InstallHistory.plist ~/Desktop
sudo emacs /Library/Receipts/InstallHistory.plist
搜索类似于以下内容的条目:
<dict>
<key>date</key>
<date>2011-09-16T22:22:10Z</date>
<key>displayName</key>
<string>Java for Mac OS X 10.6 Update 5</string>
<key>displayVersion</key>
<string>1.0</string>
<key>packageIdentifiers</key>
<array>
<string>com.apple.pkg.JavaForMacOSX10.6Update5</string>
</array>
<key>processName</key>
<string>Software Update</string>
</dict>
也
<dict>
<key>date</key>
<date>2013-01-15T11:42:35Z</date>
<key>displayName</key>
<string>Java for OS X 2012-006</string>
<key>displayVersion</key>
<string>1.0</string>
<key>packageIdentifiers</key>
<array>
<string>com.apple.pkg.JavaEssentials</string>
<string>com.apple.pkg.JavaForMacOSX107</string>
<string>com.apple.pkg.JavaSecurity</string>
<string>com.apple.pkg.JavaMDNS</string>
</array>
<key>processName</key>
<string>Software Update</string>
</dict>
并删除它们。您可能希望使用diff检查您的工作:
diff -u ~/Desktop/InstallHistory.plist /Library/Receipts/InstallHistory.plist | less
或其他文件比较工具。
您可以通过运行以下命令来测试Java是否消失:
java -version
您应该会看到一个弹出窗口,要求再次安装Java。
type java
又ls $(type -p java)
返回?