"java.exe" is not recognized as an internal or external command,

I downloaded both Java jdk1.7.0_06 and Java jre7. and I added the following system variable JAVA_HOME C:\Program Files\Java\jdk1.7.0_06\bin to my windows 7. But when I enter the following at the cmd prompt in my windows 7 C:\activiti-5.10\activiti-5.10\setup>ant demo.start , to start the demo application, I got the following error at the command line '

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

So does anyone know how I can solve this problem? BR

+7
source share
6 answers

If you look at the file "ant.bat" , you will see that it looks for the command "java" as follows:

  • If the %JAVACMD% environment variable is set, it uses it.
  • Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
  • Otherwise, it tries to use java.exe ; that is, it will look at your% PATH%.

In your case, you have %JAVA_HOME% set ... but it is installed in the "bin" installation directory in Java, and not in the installation root directory. So Ant.bat script looks in the wrong place for java.exe .

Just set %JAVA_HOME% correctly and it should work.

 JAVA_HOME C:\Program Files\Java\jdk1.7.0_06 

You do not need to have a Java “bin” directory on your %PATH% for Ant to work, but it’s a good idea anyway. This way you can run Java commands just from the command line.

The setting %CLASSPATH% does not apply to this problem. In fact, if the build.xml file does not work, Ant will ignore the %CLASSPATH% environment variable.

+13
source

You need to put the java.exe file in your PATH variable, but the JRE in JAVA_HOME

+2
source

Usually JAVA_HOME should be the parent directory of the bin folder. (jre or jdk)

In this case, ant expects java to be from the JDK.

try running in cmd window

 set JAVA_HOME=C:\Program Files\Java\jdk1.7.0_06 set path="%JAVA_HOME%/bin;%path%; ant 

(side note: adding java.exe to the path is not a requirement for ant, this is a convenient thing for the user)

+2
source

JAVA_HOME is the JDK path root folder.eg: C: \ Program Files \ Java \ jdk1.7.0_06, but the path defines C: \ Program Files \ Java \ jdk1.7.0_06 \ bin

 JAVA_HOME C:\Program Files\Java\jdk1.7.0_06 JRE_HOME C:\Program Files\Java\jre1.7.0_06 path = C:\Program Files\Java\jdk1.7.0_06\bin;C:\Program Files\Java\jre1.7.0_06\bin 
+1
source

Just delete the following set of files from the% windir / System32 folder. Actually, removing java.exe is enough, but for consistency just delete all java related binaries.

  • java.exe
  • javaw.exe
  • javaws.exe

In fact, the windows oracle installer puts a copy of these files in the% windir / System32 folder (which I don’t understand why), but it seems that they are not needed (since they are available anyway in the JDK folder where you install them).

I tried all the various solutions posted on SO and other forums, but none of them worked for me. I also correctly set all the relevant environment variables (JAVA_PATH, CLASS_PATH, etc.). Finally, this is the only solution that worked for me.

+1
source

I agree with the explanation above, but if the problem still persists, try setting: CLASSPATH = C: \ Program Files \ Java \ jdk1.7.0_06 \ bin

-one
source

All Articles