“java.exe” is not recognized as an internal or ext

2020-03-30 16:22发布

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?

标签: c# java ant cmd
7条回答
SAY GOODBYE
2楼-- · 2020-03-30 16:25

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

查看更多
地球回转人心会变
3楼-- · 2020-03-30 16:32

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.

查看更多
我想做一个坏孩纸
4楼-- · 2020-03-30 16:38

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.

查看更多
仙女界的扛把子
5楼-- · 2020-03-30 16:44

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.

查看更多
放荡不羁爱自由
6楼-- · 2020-03-30 16:46

try setting tha java path properly

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

查看更多
我欲成王,谁敢阻挡
7楼-- · 2020-03-30 16:48

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...

查看更多
登录 后发表回答