Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

java

ant

I have 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 type the following in the CMD command line on my windows 7 C:\activiti-5.10\activiti-5.10\setup>ant demo.start to run a demo application I got the following error in the command line '

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

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

like image 625
John John Avatar asked Aug 26 '12 06:08

John John


People also ask

How do I fix Java is not recognized as an internal or external command?

Here are the three easiest ways to fix Java's “not recognized as an internal or external command” error: Install or reinstall Java and the JDK on your computer. Add Java's bin directory to the computer's PATH. Restart the command prompt, terminal window or PowerShell.

Where is Java EXE located?

The java.exe ExecutablesOne copy is in the bin directory of the Java RE. The second copy is placed in either C:\windows\system or C:\winnt\system32 , depending on the system.

Is not recognized as an internal or external command operable program or batch file?

You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.


3 Answers

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

  1. If the %JAVACMD% environment variable is set, then it uses that.
  2. Otherwise, if the %JAVA_HOME% environment variable is set, it tries to use %JAVA_HOME%\bin\java.exe
  3. Otherwise, it tries to use java.exe; i.e. it will look on your %PATH%.

In your case, you have %JAVA_HOME% set ... but set to the Java installation's "bin" directory, not to the root of the installation. So the 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

As you can see from the above, you do not need to have the Java "bin" directory on your %PATH% for Ant to work, but it is a good idea to set it anyway. That way you can run the Java commands simply from the command line.

The setting of %CLASSPATH% is not relevant to this problem. Indeed, unless the build.xml file is broken, Ant will ignore your %CLASSPATH% environment variable.

like image 81
Stephen C Avatar answered Oct 21 '22 04:10

Stephen C


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

like image 35
imulsion Avatar answered Oct 21 '22 03:10

imulsion


JAVA_HOME is the path of JDK root folder.eg: C:\Program Files\Java\jdk1.7.0_06 but path define 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
like image 1
Mohammod Hossain Avatar answered Oct 21 '22 04:10

Mohammod Hossain