Raspberry Pi

How to Completely Remove Java from the Raspberry Pi OS?

Raspberry Pi is one of the most favorable platforms if one wants to learn coding or wants to get into developing applications. Like the regular computers Raspberry Pi has the potential of carrying out all the functions.

Since Raspberry Pi uses the Linux based system, the process of installing and uninstalling the application on it is like other Linux distributions. If you are done with the Java programming language or want to have a newer version of its application and looking for a way to completely uninstall it from Pi, then read this guide.

Uninstalling Java Completely from Raspberry Pi

To completely remove Java from Raspberry Pi, follow the steps given below:

Step 1: The first thing that you should do is to check the version of Java currently installed on your Pi and for that execute the following command:

$ java --version

 

Step 2: You might have multiple Java versions installed on your Raspberry Pi and default version might be another version so to set the current version default execute the following command:

$ sudo update-alternatives --config java

 

Set the current choice as default one by typing the number and pressing Enter.

Step 3:  Execute the below given command to remove the Java from your Raspberry Pi completely:

$ sudo apt remove openjdk-17-*

 

Step 4: To remove the cache files of Java now execute the following command:

$ sudo apt autoremove

 

Step 5: Now remove the directories of the both the versions of Java in Raspberry Pi and for that execute the following command:

$ sudo rm /usr/lib/jvm/Java-17-openjdk-armhf/bin/Java

$ sudo rm /usr/lib/jvm/Java-11-openjdk-armhf/bin/Java

 

To verify if Java is completely removed from Raspberry Pi, execute the following command:

$ java --version

 

Conclusion

Installing applications on Raspberry Pi is quite easy as it requires one or two commands whereas uninstalling applications and removing them completely can be a lengthy process. If you are a Linux operating system user then, it might be a piece of cake for you, whereas for new users it can be like a walk in a maze. To uninstall Java from Raspberry Pi uninstall using apt remove command then remove the cache files along with their directories.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.