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:
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:
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:
Step 4: To remove the cache files of Java now execute the following command:
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-11-openjdk-armhf/bin/Java
To verify if Java is completely removed from Raspberry Pi, execute the following command:
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.