I have java installed including jre 6 and 7 on Windows 7 64-bit. When I type java -version at the command line I get:

C:\>java -version
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

I wanted to make jre7 the default java from the command line so I went to edit my path when I notice java isn't specified anywhere in either System Variables or User Variables (nor is there a JAVA_HOME variable either). Also running set from the command line confirms this as the Path variable has no java directory. My java is stored in the normal C:\Program Files\Java\jre6.

So now I'm curious how is windows finding my current java on the command line?

  • it looks like that C:\Windows\System32\java.exe checked first, if you haven't got this file here, java.exe runs from your JDK path – Ishikawa Yoshi Jan 30 '13 at 9:43

Found a stackoverflow question which has the solution: JRE installation directory in Windows

Running where java gives the output:

C:\>where java

(Didn't realize windows had where command just knew it didn't have which.) Curious how java.exe ended up there.


This oracle article, Deploying the JRE on Windows, states that the Java installer will copy java.exe into the system directory:

By default, the installer places a copy of the runtime environment in the C:\Program Files\Java\jre1.6.0 directory. In addition, if no more recent version is already installed on the machine, the installer puts copies of the java and javaw application-launcher executables in the Microsoft Windows system directory. (The system directory varies depending on the Microsoft Windows version, but is usually either C:\winnt\system32 or C:\windows\system.)

| improve this answer | |

C:\Windows\system32\java.exe is a pretty common location.

| improve this answer | |

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.