This article is participating in “Java Theme Month – Java Debug Notes Event”, see < Event link > for more details.
** Question: Remove Java 8 JDK from Mac **
I installed JDK 8 beta some time ago to see some examples. I’m now sure that it’s easy to make changes between versions.
Use IntelliJ for some application development. For some reason, even though IntelliJ is still compiled using Java 8:
1. I set up the compiler in my preferences to use Java 1.6
2. SBT works on the command line, even though it uses SBT through an external build
- JAVA Home points to JDK 6
If I go to the Java Preferences page, it does show that Java 8 is installed, but there is no uninstall option, and I don’t see any other versions.
When I run which Java, it tells me /usr/bin/java, so when I run /usr/bin/java-version, it returns 1.6.
Answer 1:
I was able to successfully perform the following steps and uninstall JDK 8:
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk<version>.jdk
Copy the code
To remove the plug-in, run the following command
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
Copy the code
Answer 2:
All you need is these three lines of code:
sudo rm -rf /Library/Java/*
sudo rm -rf /Library/PreferencePanes/Java*
sudo rm -rf /Library/Internet\ Plug-Ins/Java*
Copy the code
Answer 3:
Use /usr/libexec/java_home; I found these aliases and functions used in my ~ /.profile as well.
alias java_ls='/usr/libexec/java_home -V 2>&1 | cut -s -d , -f 1 | cut -c 5-'
function java_use(a) {
export JAVA_HOME=$(/usr/libexec/java_home -v $1)
java -version
}
Copy the code