You will encounter this message if you are trying to run a Java instruction on a system with a faulty or corrupted Java Environment. In most cases, this is an error that will appear after a Java removal from the system or inappropriate Java installation.
Why this error occurs ?
Three immediate causes pop into my mind:
- If for any reason you remove Java from your system and then you try to run a code or a function/instruction that needs Java environment (this would be at least weird, unless it is for testing purposes or some other crazy logic that stands behind the fact that you just removed the software and now you are trying to do something that would use what you removed).
- If for any reason you don’t have Java ‘correctly’ installed but you are trying to use a Java enabled code/function/instruction (like in the case of a malfunction, or some action that would trigger the removal of the Java software from your computer).
- If you just installed Java environment and the instruction or code you are about to use, needs a reference to the Java home location, and we are talking here about the location of the ‘bin’ directory being added to the System Environment, in PATH.
For a clean Java installation, you can find the latest versions in here: http://www.java.com/en/download/manual.jsp
I will give you a specific case that I’ve dealt with in order to summarize and present the solution. A user needed Java environment for some application development, so we decided to install a version of his choosing, in our case JDK 6 update 38. As a hint, JDK also installs JRE.
We installed the JDK environment and when the user wanted to run a simple command in a command line to return the java version (as a test that you can always do as long as you have Java installed, which should return the version), we got the error that you can also see in the title: Java is not recognized as an internal or external command, operable program or batch file.
In other words, the instruction can’t be executed because the Java location is not known to the system.
Solution for Java is not recognized as an internal or external command, operable program or batch file :
To correct this error we have to add the location of the current Java environment we want to use to the System’s Environment PATH, to be more precise the bin directory where Java has been installed.
You can access the system environment menu by going to Start – Settings – Control Panel – System (the navigation through control panel can be avoided if you just type in a run – “sysdm.cpl” without the quotes. Now you can resume with the next of the steps – advanced – environment variables.
Locate Path, in System variables as you can see above, select it and use the edit button. Then you will have to add a semicolon (;) at the end of the line, followed by the location of the Java bin directory on your system.
For example, this is what I had to add, considering the fact that C:\Program Files\Java\jdk1.6.0_38\bin is the location of my Java installation. You should find yours in a similar directory, if you’ve used the default path for installation.
Now, the only thing to do is to confirm with OK two times as you have two windows to close. Also close the command interpreter, in our case command prompt, re-open it, and the command will work now, as you can see below.
Note: The location to the Java bin directory would be slightly different on 64 bit operating systems like Vista and Windows 7, as the “Program Files” folder will be actually “Program Files (x86)”.
Now, you can also run the program or instructions you wanted to work with before this happened. Simple as that.
VN:F [1.9.22_1171]Java is not recognized as an internal or external command, operable program or batch file,