Tip - Locating Commands In The Path On Windows
[Tips]
Assume you have a command like so:
This is the Java compiler, part of the Java JDK. It works from wherever I am without me having to specify the complete path because it is in my PATH environment.
But what if you wanted to know where exactly it was? It is possible to have more than one JDK installed, and there are times you want to know where exactly the executable is located.
To do this, run the this command:
where.exe javac
(note the .exe
) if you are using PowerShell (or PowerShell Core). This is because where without the exe will be interpreted as an alias for where-object
If you are using the Windows Command interpreter (cmd.exe), run just
where javac
Where.exe is a program packaged with Windows for this very purpose.
You should get a response like this:
Here you can see exactly where the binary is located.
Happy hacking!