Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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

2 Answers 2

up vote 4 down vote accepted

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

Running where java gives the output:

C:\>where java
C:\Windows\System32\java.exe

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

Update

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.)

share|improve this answer

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

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.