Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between "system32\java.exe" and "Program Files\Java\jdk1.6.0_33\bin\java.exe"?

I have just installed Java JDK 6u33 in Windows XP. Even though I didn't set the PATH environment variable, I am able to run java -version in command prompt.

When I run this command for %i in (java.exe) do @echo. %~$PATH:i, I get this output: C:\WINDOWS\system32\java.exe

When I check my PC, I found that there are 2 java.exe:
1. C:\Program Files\Java\jdk1.6.0_33\bin\java.exe
2. C:\WINDOWS\system32\java.exe

May I know what is the difference between system32\java.exe and Program Files\Java\jdk1.6.0_33\bin\java.exe? Why only system32\java.exe is shown when I run for %i in (java.exe) do @echo. %~$PATH:i?

Do I still need to add C:\Program Files\Java\jdk1.6.0_33\bin\ to my PATH environment variable?

like image 363
userpal Avatar asked Jun 16 '12 13:06

userpal


People also ask

What is the path to Java EXE?

The java.exe Executables Two copies of the java.exe executable are installed. One copy is in the bin directory of the Java RE. The second copy is placed in either C:\windows\system or C:\winnt\system32 , depending on the system.

Where is java in system32?

The java.exe in \windows\system32\ is provided so that not everyone needs to set a PATH variable just to run a java program (from the command line) and selects a version (the last one installed it seems) of the installed java virtual machines (JVM) if there are more than one (publicly) installed.


2 Answers

Setting the PATHvariable is just so that you can get access to javac and the other programs and tools in the jdk bin folder.

The java.exe in \windows\system32\ is provided so that not everyone needs to set a PATH variable just to run a java program (from the command line) and selects a version (the last one installed it seems) of the installed java virtual machines (JVM) if there are more than one (publicly) installed.

See this link for further info:

http://mindprod.com/jgloss/javaexe.html#MULTIPLES

Quote:

To complicate things further the java.exe in system32 is just a dummy. It looks in the registry and then decides which real java.exe to use. The last JVM installed gets to be the one used, even if it is older. To switch JVM s, you must normally reinstall the one you want.

like image 56
Mattias Isegran Bergander Avatar answered Oct 23 '22 15:10

Mattias Isegran Bergander


(Not an answer but rather a comment on Mattias's answer) Not sure about this "dummy" business. The java.exe in system32 is a normal file, not even a symbolic or hard link. Mattias may be referring to the problem that is explained here: http://msdn.microsoft.com/en-us/library/aa384187

In a nutshell, if you have a 64-bit system and a Java installation, 32-bit applications won't see the java.exe (nor javaw.exe, javaws.exe) that is installed in C:\Windows\System32\ because they'll be presented with C:\Windows\SysWoW64\ masquerading as C:\Windows\System32. The installer fails to put a copy of java.exe in SysWoW64, hence a 32-bit app that tries to launch Java will fail to do so. This will puzzle the user if he looks in the system32 directory using explorer, since explorer is a 64-bit app and will thus see the "real" system32 directory.

like image 36
Urhixidur Avatar answered Oct 23 '22 16:10

Urhixidur