Skip to content

Uninstall Java (manually)

Zhamri Che Ani edited this page Nov 19, 2025 · 2 revisions

Remove OpenJDK 19.0.2 (manually installed)

  1. Check the location
/usr/libexec/java_home -V

Example:

/Users/zhamri/Library/Java/JavaVirtualMachines/openjdk-19.0.2
  1. Delete JDK
rm -rf /Users/zhamri/Library/Java/JavaVirtualMachines/openjdk-19.0.2

If permission is denied, use sudo:

sudo rm -rf /Users/zhamri/Library/Java/JavaVirtualMachines/openjdk-19.0.2

If JAVA_HOME still points to Java 19

Edit your ~/.zshrc

vim ~/.zshrc

Remove this line if present:

export JAVA_HOME="/Users/zhamri/Library/Java/JavaVirtualMachines/openjdk-19.0.2/Contents/Home"

Add this (for Java 21):

export JAVA_HOME="$(/usr/libexec/java_home -v 21)"

Reload:

source ~/.zshrc

Clone this wiki locally