When I do which java I get the following output:

which java

I have already uninstalled java rpm using the following

`rpm -qa | grep -i java`
rpm -e rpm-name

Still java is not installed and which java brings up /dir/java/bin/java

  • 1
    That sounds like it was installed outside of rpm (or yum/dnf), so it's not in the database. – Aaron D. Marasco May 31 '19 at 0:09
  • How to remove java in such a scenario? – meallhour May 31 '19 at 0:16

Apparently Java may have been installed outside of rpm package management.

In that case, you could just do a mv /dir/java /dir/java.to-be-removed, then verify that nothing essential gets broken by this.

If all seems OK, then remove any references to /dir/java/bin in system-wide PATH and MANPATH settings (check /etc/environment, /etc/profile, and the files in /etc/profile.d directory if it exists) , delete any system-wide JAVA_HOME environment variable settings, and finally remove the /dir/java.to-be-removed directory altogether.

You might also check that /usr/local/bin directory doesn't contain any now-broken symbolic links pointing to the various tools within /dir/java/bin.


try to find destination dirs from below commands.

which java


/usr/sbin/alternatives --display java

One you find out delete those folder itself.

Since you already tried rpm way I am not adding. But be aware some other software which require java may not work after complete removal.


Adding to the other answers; if you don't know whether a file belongs to an rpm or not, you can use:

rpm -qf /path/to/file

Which tells you to what rpm that file belongs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.