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?
You should check your PATH variable. You can use the set
command to set the correct path to your java environment folder.
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.
try setting tha java path properly
can u give me the exact error message u get...
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.
I also ran into the same problem and found my solution. It might help you too.
- 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.
- At command prompt changed the current directory to java.exe parent directory.
- 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.
If you have multiple values in your PATH variable, make sure they are not separated with a space following the end semi-colon (;)
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...