Why is java.exe not visible from cygwin, but is visible from command-prompt?

12

4

Why can't I see java.exe from Cygwin?

Cygwin vs Win8

Chloe

Posted 2013-03-08T19:51:36.853

Reputation: 4 502

Answers

14

In x64 editions of Windows 8/7/Vista, contents of C:\Windows\System32 folder depend on the bitness of the application .

For 64-bit applications (such as Windows Command Prompt, cmd.exe) there's no filesystem redirection:
C:\Windows\System32 (in software) -> C:\Windows\System32 (on disk).
So, C:\Windows\System32 folder contains 64-bit DLL and EXE files, from the point-of-view of 64-bit application.

For 32-bit applications (such as bash.exe from Cygwin) which runs via WoW64 subsystem on Windows x64, there are two redirections in the filesystem:
C:\Windows\System32 (in software) -> C:\Windows\SysWOW64 (on disk).
C:\Windows\Sysnative (in software) -> C:\Windows\System32 (on disk).
So, C:\Windows\System32 folder contains 32-bit DLL and EXE files, from the point-of-view of 32-bit application.

If you want to access 64-bit applications and DLL files (such as java*.exe) from 32-bit applications (such as Cygwin's bash.exe), you need to use C:\Windows\Sysnative path, or /cygdrive/c/Windows/Sysnative in Cygwin notation.

(this is an updated and extended answer)

Mikhail Kupchik

Posted 2013-03-08T19:51:36.853

Reputation: 2 381

Yes, they are there: Chloe@xps /cygdrive/c/Windows/sysnative $ ls -la java* -rwx------+ 1 SYSTEM SYSTEM 188320 Mar 7 04:43 java.exe – Chloe – 2013-03-08T19:56:45.377

Why does it do that? I can't see sysnative from DOS prompt. – Chloe – 2013-03-08T20:00:04.343

2

So, cygwin's bash.exe runs as 32-bit application and in that context C:\Windows\System32 is mapped to C:\Windows\SysWOW64 (a folder without java* files). Windows command prompt (cmd.exe) runs as 64-bit application and so it is able to see true C:\Windows\System32. Use C:\Windows\sysnative to access true system32 directory from 32-bit applications. More information on this topic: http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187%28v=vs.85%29.aspx

– Mikhail Kupchik – 2013-03-08T20:00:40.380

Wow that is totally backwards and confusing! – Chloe – 2013-03-08T20:11:06.853

1Yes, they should have made \Windows\system64 directory for 64-bit system DLL and EXE files, but unfortunately we have 64-bit files in System32 directory and awkward filesystem redirection. – Mikhail Kupchik – 2013-03-08T20:14:55.183