Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

6 Answers 6

up vote 4 down vote accepted

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.

share|improve this answer
    
"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
    
Perfect! Thanks. –  Andrew Aug 25 '09 at 15:39
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! –  Darth Satan 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. –  Andrew Aug 25 '09 at 15:49

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
share|improve this answer
    
The dir /s is a good option; the output can then be cross-referenced with the PATH contents. –  Andrew Aug 25 '09 at 15:43

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

share|improve this answer
    
You may need to add the directory where you installed which to your PATH. –  Sean Staats Aug 25 '09 at 15:10

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

share|improve this answer

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

share|improve this answer

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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