# Linux – “which” and “whereis”

linux

On my linux box, after typing which java, I get

/usr/bin/java

After typing whereis java, I get

java: /usr/bin/java /etc/java /usr/share/java /usr/share/man/man1/java.1.gz

What are the meanings of these two results? When setting up the JAVA_HOME, which one should I use?

• which   (1) - shows the full path of (shell) commands

I'd use which as it shows you where just the binary is as I assume that is all you need. However Java could be installed somewhere else and which would not report it as it only searches for an executable or script in the directories listed in the environment variable PATH.