Hamid62
Hamid62

Reputation: 183

"java.exe" is not recognized as an internal or external command, operable program or batch file

I am writing an application that creates a Java portlet by the ant batch file with the cmd.exe using a Process object in C#.

When I pass the "Create" command to the cmd to create portlet, I receive an error like this:

'"java.exe"' is not recognized as an internal or external command,
operable program or batch file.

But when I type this command on the cmd directly, that works correctly.

I've installed the JDK on my windows 7 and set the JAVA_HOME and ANT_HOME variables in the Environment Variables. Can you help me to correct that?

Upvotes: 1

Views: 5074

Answers (7)

LazyCoder
LazyCoder

Reputation: 21

I had the same problem and solved it. I'm using 64-bit Windows 7 with 64-bit Java. Setting the compile target in the Configuration Manager to 'x64' solved it. If you use 'any CPU' the build probably falls back to 'x86', which is not working with 64-bit Java. So you need different builds for different machines...

Upvotes: 0

Colin
Colin

Reputation: 35

If you have multiple values in your PATH variable, make sure they are not separated with a space following the end semi-colon (;)

Upvotes: 0

Umer
Umer

Reputation: 1921

In my experience, this problem had nothing to do with Java path. Actually I had installed java for 64 bit machine and had compiled my C# program with 32 bit settings. Calling a 64Bit program was not possible from a 32bit program. So i changed my Target platform to "Any CPU" and it worked fine.

Upvotes: 1

mackie1908
mackie1908

Reputation: 475

I don't know if this will help anyone else that is viewing this post but when i had this problem it was because I was running a x64 machine and the java.exe was installed to the ProgramFiles(x86) folder. I simply added the path to the exe to the 'PATH' environment variable and then it fired up just fine.

Hope this helps someone.

Upvotes: 2

iMatoria
iMatoria

Reputation: 1448

I also ran into the same problem and found my solution. It might help you too.

  1. Set the PATH variable. I don't know if this step is required or not, but i just added the path to java.exe in TEMP variable.
  2. At command prompt changed the current directory to java.exe parent directory.
  3. Now ran to command which i required. If some file is been referenced in the command then i put the complete path.

Hope it helps you.

Upvotes: 0

Mohamed Jameel
Mohamed Jameel

Reputation: 602

try setting tha java path properly

can u give me the exact error message u get...

Upvotes: 1

peponline
peponline

Reputation: 83

You should check your PATH variable. You can use the set command to set the correct path to your java environment folder.

Upvotes: 4

Related Questions