3

Installed Java 1.7 on Windows Server 2008. In Cygwin I can clearly see that "which java.exe" returns c:\Windows\System32\ even running "java -version" returns 1.7. But on Windows command prompt and/or Powershell it complains it is not a recognized internal or external command.

Nor I can see the file in Windows explorer in the above mentioned path. Even after changing folder options in Windows explorer.

The Java version installed is 64-bit on Windows Server 2008. It is a ditto behavior on Window 7 as well.

Does anyone know how to fix this issue?

Thank you in advance for any help.

-RG

Rg Glpj
  • 423
  • 2
  • 5
  • 10

4 Answers4

3

I believe this is because your OS is 64 bits, but your installed version of Java is 32-bits. A 32-bit shell (Cygwin's bash or in my case MSYS' sh) can see and run it, but a 64-bit shell (cmd) cannot.

  • Don't they say that their java version is 64 bit? – Chris Mar 21 '13 at 12:33
  • The OP stated that its *OS* is 64-bits. But nothing prevents you (or me for that matter...) from installing a 32-bits Java. If you don't extend your CMD path with 32-bit Java folder, CMD will not find it. This is because a plain 32-bits java installation creates a java.exe in c:\Windows\SYSWoW64, that 32-bits applications transparently access as c:\Windows\System32... (a "feature" called File System Redirector[1]). 64-bits applications access the "real" c:\Windows\System32, where no such java.exe exists. [1]:http://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx – user2195045 Mar 21 '13 at 13:48
  • Very true, but OP states `The Java version installed is 64-bit on Windows Server 2008. It is a ditto behavior on Window 7 as well.` – Chris Mar 21 '13 at 14:08
  • I missed that bit, sorry. Yet, all the symptoms are consistent with the OP having installed a 32-bit Java on its 64-bit OS. It may help resolve the issue if the OP could determine (using Windows Explorer) whether a java.exe exists in c:\Windows\SYSWoW64. – user2195045 Mar 21 '13 at 14:40
  • Yes. I do see java.exe in c:\windows\syswow64. Is there a option on java.exe that will tell me whether it is 32 or 64 bit. From above explaination from user2195045 it appears that I have 32-bit installed, it is partly because java/com/en/download/chrome.jsp does not give me an option to choose binary. So could it be that I have 32-bit chrome browser which lead java site to redirect me to 32-bit download... – Rg Glpj Mar 21 '13 at 21:52
  • You can use Cygwin's "file" command, which (unlike MSYS...) will explicitely tell you if a PE executable is 32 or 64 bits (MSYS tells you it's a "Mono/.Net assembly") You can also start java --version. Oracle's java.exe 64-bit explicitly states so. 32-bit is mute about it. – user2195045 Mar 22 '13 at 08:34
3

Try to use cygwin64, or put %JAVA_HOME%\bin at the start of PATH environment variable.Because https://superuser.com/questions/563016/why-is-java-exe-not-visible-from-cygwin-but-is-visible-from-command-prompt

Community
  • 1
  • 1
zombielei
  • 163
  • 1
  • 8
1

You might have to set your environmental variables to point to your JAVA installation.

http://java.com/en/download/help/path.xml

Austin
  • 4,801
  • 6
  • 34
  • 54
  • I had used Java installer which sets the JAVA_HOME variable plus Java was installed in C:\Windows\System32 which is by default available in %PATH% environment variable. I still don't know why I can't run Java from Windows command prompt. I gave up on that and instead launch java (or .jar programs from Cygwin window.) This behavior I have only seen in Windows Server 2008. The same Java installation on Windows 7 behaves normal. Still open to hear any one's solution. – Rg Glpj Oct 28 '12 at 00:34
  • @RgGlpj Post what your %PATH% variable is exactly. – Austin Oct 28 '12 at 05:19
0

I know this question is old but I needed the answer and didn't find it here so I will provide it for others:

Enter the variable value as the installation path for the Java Development Kit. If your Java installation directory has a space in its path name, you should use the shortened path name (e.g. C:\Progra~1\Java\jre6) in the environment variable instead.

Icon Note for Windows users on 64-bit systems

Progra~1 = 'Program Files' Progra~2 = 'Program Files(x86)'

Source of answer came from atlassian.

OutOFTouch
  • 1,017
  • 3
  • 13
  • 30