How to Uninstall Java & JDK on Mac: Step-by-Step Tutorial
How to Uninstall Java & JDK on Mac: Step-by-Step Tutorial
Java is a popular programming language that is used in many applications. In the past you had to install Java on your computer to run Java programs. Today, however, most modern Java applications are bundled with it, so it's not as crucial to install Java on your computer anymore. Keeping old Java versions installed can also lead to security vulnerabilities. No matter the reason, removing Java on macOS might look intimidating—but the process is pretty easy, especially since we've included all the Terminal commands you need to complete the task.
Ways to Uninstall Java on Mac

Via the Terminal

Ensure you have administrator privileges. Only administrators can uninstall Java via the Terminal. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step. Otherwise, you can add or remove administrators in the Users & Groups section of an administrator account's System Settings. For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article.

Open the Terminal. There are a couple of ways you can do this: Click the magnifying glass in the upper-right corner and search for "Terminal." Open the Finder and go to Utilities > Terminal.

Run the following commands. These commands should be run one at a time. To run them, simply copy and paste a command into your Terminal and press Return. Repeat this for all three commands. sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane sudo rm -fr ~/Library/Application\ Support/Oracle/Java After you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer.

Close the Terminal. After all three of the commands have been run, you can exit the Terminal. If you have the Java Software Development Kit (JDK) installed, jump to this section to learn how to uninstall it. If you don't have the JDK installed, you can instead jump to this section to learn how to remove the Java Deployment cache.

Via the Installer

Open the Java installer. If you still have the Java installer on your Mac, you can use it to uninstall Java. If you have the most recent version of Java installed but you don't have the installer still, you can download the installer from Java's website. However, if you have an older version of Java, running the installer may install the newer Java version alongside the older Java version instead of replacing it. If you have an old Java version it's better to uninstall via the Terminal, explained above.

Enter your computer's admin password, if prompted. If you've only ever had one account on your Mac, the first one you created is automatically an administrator. However, if you need to make your account an administrator you can do so in the Users & Groups section of an administrator account's System Settings. For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article.

Click Remove. It's in the bottom-right corner of the "Welcome to Java" dialog box. Allow the uninstaller to finish processing before moving on.

Click the Apple menu and select System Settings…. If you're on an older version of macOS, you will see System Preferences… instead.

Look for the Java panel at the bottom of the sidebar. If you still see it, Ctrl+click on it and select "Remove Java Settings pane". After removing the Java Settings pane, you can exit out of your System Settings menu.

Click on the Finder, then navigate to Go > Go to Folder. Alternatively, you can press Cmd+Shift+G to open the Go to Folder window.

Go to the following locations and delete any remaining Java files or folders. Copy and paste each file path below into Go to Folder, look for any files or folders that have "Java" in the name, and drag those files/folders to the Trash. /Library/Application Support/Oracle /Library/Java/ /Library/Internet Plug-ins/ /Library/PreferencePanes

Empty the Trash. Open the Trash folder on your desktop and empty it to fully delete any and all straggling Java files you found buried in your computer's directories. If you have the Java Software Development Kit (JDK) installed, jump to this section to learn how to uninstall it. If you don't have the JDK installed, you can instead jump to this section to learn how to remove the Java Deployment cache.

Uninstalling the JDK

Ensure you have administrator privileges. Only administrators can uninstall JDK. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step. Otherwise, you can add or remove administrators in the Users & Groups section of an administrator account's System Settings. For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article.

Uninstall the Java Runtime Environment before uninstalling the JDK. We explain how to do this earlier in the article. Check out the first section to uninstall Java with the terminal and the second section to uninstall Java with the installer.

Open the Terminal. There are a couple of ways you can do this: Click the magnifying glass in the upper-right corner and search for "Terminal." Open the Finder and go to Utilities > Terminal.

Change the directory of the Terminal to your Java Virtual Machines folder. To do this, copy and paste the following command into the Terminal and hit Return. cd /Library/Java/JavaVirtualMachines

Run a list command to see which versions of JDK you have installed (optional). If you know which JDK version you have installed, you can skip this step. If you aren't sure which JDK version(s) you have installed, copy and paste the following command into the Terminal and press Return: ls --directory *jdk* The Terminal will list all of your JDK versions in the format jdk-1.#.jdk, with the hashtag (#) being the number of your version.

Run a remove command to remove your desired JDK version(s). Copy and paste the command below into Terminal and press Return to run it. Make sure to replace the hashtag (#) with the JDK version number you want to remove. sudo rm -rf jdk-1.#.jdk After you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer. If you want to remove more than one JDK installation, add more JDK paths separated with a space. Just be sure to change the hashtag (#) to the correct version number.

Run the Java command to ensure it's removed. Enter java into the Terminal and press Return. You should get an error that says "No Java runtime present, requesting install." If you don't get an error stating that Java is uninstalled, follow the steps in this guide again. Once Java and the JDK are uninstalled, continue on to this section to learn how to remove the Java Deployment cache.

Removing the Java Deployment Cache

Ensure you have administrator privileges. If you're using the first account created on your Mac, it's an administrator by default, so you can skip this step. Otherwise, you can add or remove administrators in the Users & Groups section of an administrator account's System Settings. For a more in-depth guide on how to set your account as an administrator on Mac, check out this wikiHow article.

Open the Terminal. There are a couple of ways you can do this: Click the magnifying glass in the upper-right corner and search for "Terminal." Open the Finder and go to Utilities > Terminal.

Run the following command. Copy and paste the command below into the Terminal and press Return to run it and remove the Java Deployment cache. The Java Deployment cache stores various Java files and settings, but isn't always removed when you uninstall Java or JDK. sudo rm -r ~/"Library/Application Support/Oracle/Java" After you run a sudo command for the first time, the Terminal will ask for a password. Enter the password you use to login to your computer.

What's your reaction?

Comments

https://chuka-chuka.com/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!