A Guide on How to Remove Java in CentOS
By Chris Hoffman
CentOS, a community enterprise operating system based on Red Hat’s Enterprise Linux, supports Oracle’s Java runtime environment and development kit software. You can remove Java if you’ve installed it by uninstalling the RPM package from your system or deleting the directory you manually installed Java into. The method you should use depends on the way you installed Java; don’t just delete Java’s folder if you installed Java with an RPM package.
Open a terminal window by clicking the “Applications” menu, pointing to “Accessories” and clicking “Terminal.”
Become the root user by typing “su” into the terminal and pressing “Enter.” Type the root account’s password and press “Enter” to authenticate.
Type “rpm -qa | grep java” into the terminal and press “Enter.” The name of each installed Java package appears in the terminal.
Type “rpm -e package” into the terminal, replacing “package” with the name of the Java package from the previous command. You can remove multiple packages by separating each package name with a space.
Press “Enter” to run the command and remove the packages.
Open a terminal window by clicking “Applications” on the panel, pointing to “Accessories” and selecting “Terminal.”
Type “su” into the terminal and press “Enter.” Type the root password at the password prompt and press “Enter” to become the root user.
Locate the directory you installed Java to. Try using the “which java” command, which tells you the location of the Java binary file on your system. The location is often “/usr/java”, “/opt/jre_nb” or a subdirectory in “/usr/local/”.
Type “rm -r /opt/java” into the terminal, replacing “/opt/java” with the directory Java is installed in.
Press “Enter” to run the command and delete the directory.
Ensure that you’re deleting only the Java folder itself. For example, using a command such as “rm -r /bin” or “rm -r /user” will delete important system files and break your system.
Chris Hoffman is a technology writer and all-around tech geek who writes for PC World, MakeUseOf, and How-To Geek. He's been using Windows since Windows 3.1 was released in 1992.