0

I'm trying to determine the location of an executable (java.exe) on Windows. I know it must exist somewhere in the PATH since I can run it, but I don't know the exact directory that it is being run from. On a UNIX system I could use the whence command to obtain this information. Is there an equivalent command for Windows systems?

5

On my Vista laptop if I type "where java.exe" from the command prompt it gives me the location of java.exe.

Hope this helps.

  • "where" works on Windows 2003 and Win 7 too. Does not appear to be part of XP though. – Chris_K Aug 25 '09 at 15:24
  • 1
    where.exe can be copied directly from a 2003 box to an XP box and will work fine there. just do "where where.exe" to locate it! – Maximus Minimus Aug 25 '09 at 15:40
  • @mh It's in C:\Windows\System32 on my machine. Running "where where" (no extension is needed) finds it. – An̲̳̳drew Aug 25 '09 at 15:49
1

Not exactly. You have a few choices:

  • At a command prompt from the root of C: run: Dir /s java.exe
  • install the win32 port of which.exe (there may be a whence.exe port too)
  • use the search functionality in windows explorer
  • get one of several third party windows file indexing and searching utilities
  • The dir /s is a good option; the output can then be cross-referenced with the PATH contents. – An̲̳̳drew Aug 25 '09 at 15:43
1

Install this: http://gnuwin32.sourceforge.net/packages/which.htm Then open a command prompt and type: which java

  • You may need to add the directory where you installed which to your PATH. – Sean Staats Aug 25 '09 at 15:10
0

In a command prompt type "path".... that will give you your path you can also use the "find" command.

0

Check out the first Google hit for "equivalent whence windows". You'll have to write a small utility to do it.

0

Here's a "whereis" script from Raymond Chen's blog:

http://blogs.msdn.com/oldnewthing/archive/2005/01/20/357225.aspx

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.