To uninstall Java from a macOS computer using the terminal, you can follow these steps:
Open the terminal on your macOS computer.
Run the following command to remove the Java runtime and JDK:
sudo rm -rf /Library/Java/JavaVirtualMachines/*
This will delete the Java virtual machine (JVM) and JDK files from your system.
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/Application\ Support/Oracle/Java
This will delete any remaining Java directories or files that may have been left behind after the uninstallation process.
PATH
environment variable to ensure that it does not contain any references to the Java installation. You can do this by running the following command:echo $PATH
If the PATH
variable contains any references to the Java installation, you can remove them by editing the ~/.bash_profile
file. Open the file in a text editor and remove any lines that contain java
or javac
. Save and close the file, then reopen the terminal to apply the changes.
After following these steps, Java should be completely removed from your macOS system.