Remove JDK Instructions

User
remove one jvm
Assistant
To remove one JDK from the system (assuming this is a Linux system like Ubuntu based on the path style in the screenshot), follow these steps using the terminal:

### 🔧 **To Remove a Specific JDK (e.g., Java 11 or Java 17):**

First, list installed Java versions:

sudo update-alternatives --config java

Then, uninstall the unwanted version. For example:

– To remove **Java 11**:

sudo apt remove openjdk-11-jdk

– To remove **Java 17**:

sudo apt remove openjdk-17-jdk

You can also remove the runtime only (JRE):

sudo apt remove openjdk-11-jre
sudo apt remove openjdk-17-jre

### 🧹 Optional Cleanup

sudo apt autoremove

Let me know which version you want to keep, and I’ll give you the exact command.

User
Still showing in in usr/lib/jvm two jdk
Assistant
If the JDK folders still appear in `/usr/lib/jvm` after uninstalling with `apt`, it likely means:

– They were **manually installed**, not through APT.
– Or their directories were **not removed** during uninstall.

### ✅ To Completely Remove a JDK from `/usr/lib/jvm`:

1. **Check what's in the folder**:

ls -l /usr/lib/jvm

You’ll probably see:

java-11-openjdk-amd64
   java-17-openjdk-amd64
   openjdk-11
   openjdk-17

2. **Delete the one you don’t want**:
For example, to delete **Java 11**:

sudo rm -rf /usr/lib/jvm/java-11-openjdk-amd64 /usr/lib/jvm/openjdk-11

Or to delete **Java 17**:

sudo rm -rf /usr/lib/jvm/java-17-openjdk-amd64 /usr/lib/jvm/openjdk-17

3. **Clean up alternatives if needed**:

sudo update-alternatives --remove-all java
   sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-17-openjdk-amd64/bin/java 1

Let me know which JDK you want to **keep**, and I’ll tailor the command accordingly.

Leave a Comment

Your email address will not be published. Required fields are marked *