I have a cmd open (Windows 7), and I type "java.exe", and the system finds the executable at c:\program files\java\jre6\bin.

However, this folder is not in the path. What other mechanism affect the exe lookup?

  • Is there any variable like JRE_HOME , JAVA__HOME in your path,It can also execute
    – ukanth
    Oct 6, 2009 at 11:31

3 Answers 3


Starting with Vista and above, Windows now includes a utility called where. This program functions just like you'd expect the unix counterpart to (I'm glad they added it!)


C:\>where java

What's even nicer about where is that it'll show you all executables it finds within your path, so if you also had java.exe in C:\Windows it would show up under the \System32\ one.


I figured I'd also include an option for XP users that would like the functionality without third party tools. Raymond Chen wrote a command script in A 90-byte "whereis" program. It's a nice one liner that accomplishes the same task!

@for %%e in (%PATHEXT%) do @for %%i in (%1%%e) do @if NOT "%%~$PATH:i"=="" echo %%~$PATH:i

Save the above script in a .bat or .cmd file and you can launch it from the command line with the filename as the argument. It'll work just like you expect! (note, if using the script version, leave off the extension, it'll search all executable extensions for you)

  • 2
    +1 Always prefer a native solution 'where' possible :)
    – Phoshi
    Oct 6, 2009 at 13:42
  • +1; never knew about this command before! (And I used to think I was pretty handy with the command line!)
    – John Rudy
    Oct 6, 2009 at 13:56
  • +1 for new-to-me. It works similarly to the find command in Unix (unlike the find command in DOS or Windows). You can do where -r \users\username\documents *.xl* for example. Oct 6, 2009 at 18:12
  • +1 thanks for the XP script - I saved it as where.bat and it works just like vista would! :)
    – Bohemian
    Sep 3, 2012 at 1:37
  • The *nix equivalent is "which". The "where" one is a script on redhat perhaps for people that forget that it is 'which' on *nix
    – barlop
    Jul 6, 2014 at 6:50

there's a copy of java.exe in c:\windows\system32 (which is a path defined in the environment variables). that's the one that comes up when you type java.exe at the command prompt, not the one in c:\program files\java\jre6\bin.

  • You don't say. I tried using 'which.exe' to find it, but it didn't.
    – ripper234
    Oct 6, 2009 at 11:35
  • works for me. which which are you using? Oct 6, 2009 at 13:24
  • 2
    My which is cygwin's which and which java whiched the java.exe in /system32, so whichever which you're using might be bewitched.
    – Phoshi
    Oct 6, 2009 at 13:41
  • gnuwin32's which.
    – ripper234
    Oct 6, 2009 at 13:44
  • cygwin which here too. (witch hair 2?) Oct 6, 2009 at 14:15

There is an another way to look up files location in path using powershell:

(Get-Command java).Source

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .