How to uninstall Java JDK from mac OS? 如何解除安裝 Mac 上的 Java JDK?

BryantJZ
1 min readJul 10, 2019

--

You can get official oracle instruction to remove java from macOS here . Oracle 官網的 JDK 移除方式可以參考 這裡

Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool. 注意:您必須具備管理員權限,並以 root 身分或使用 sudo 工具執行移除命令,才能解除安裝 Java。

In your macOS terminal type this one by one. 開啟 macOS 上的終端機然後依序一一輸入以下的指令

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin 
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Oracle/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 會重設其中的所有變更。

After that you can navigate to specific version of java that you intend to delete by using the following command. 接著輸入以下指令,進到 JDK 的安裝路徑。

cd /Library/Java/JavaVirtualMachines

Then type ls in your terminal to list down all the Java Virtual Machine Folders. 進到 JDK 的安裝目錄後,輸入指令 ls ,會列出目前所有已安裝版本的 JDK。

Type the version number you want to delete like this. 輸入你想要移除的 JDK 版本指令如下範例,請輸入你電腦中實際已安裝的版本號,要留意不同版本的版號格式略有不同。

sudo rm -rf jdk-10.0.1.jdk

sudo rm -rf jdk-9.0.1.jdk

sudo rm -rf jdk1.8.0_111.jdk

sudo rm -rf jdk1.7.0_79.jdk

Finally, type “java -version” to check java is gone. It should give “No Java runtime present, requesting install.” means that you have uninstall all the JDKs in your computer. 最後輸入 “java -version” ,會彈出 “若要使用「java」命令行工具,您必須安裝 JDK。”提示訊息的視窗,即代表已將電腦裡所有的 JDK 都移除完畢了。

--

--