Java is not recognized as an internal or external command

Java is not recognized as an internal or external command

You need to configure your environment variables, JAVA_HOME and PATH.

JAVA_HOME must contain the path to java, and you should add %JAVA_HOME%bin to PATH

Alternatively, you can simply add to your PATH the whole path to the bin folder, without the JAVA_HOME variable, however, this makes a little more annoying when you need to have more than one java version on your machine (that way you only need to change JAVA_HOME and dont even bother with PATH)

For Windows 7:

  1. Right click on My Computer

  2. Select Properties

  3. Select Advanced System Settings

  4. Select the Advanced tab

  5. Select Environment Variables

  6. Select Path under System Variables

  7. Click on the Edit button

  8. In Variable value editor paste this at the start of the line

    C:Program FilesJavajdk1.7.0_72bin;
    
  9. Click Ok then Ok again

  10. Restart command prompt otherwise it wont see the change to the path variable

  11. Type java -version in the command prompt.


Notes on Step 8:

  1. The version of java in this may be different from the one used here — this is only an example.
  2. There will probably be other values in the path variable. It is really important that you dont delete whats already there. Thats why the instructions say to paste the given value at the start of the line — this means that you dont remove the existing value, you just put java before it. This also fixes any problems youd be getting if an other version of java is also on the path.

Notes on Step 6:

  1. This sets the path for the computer, not for the individual user. It may be that youre working on a computer which other developers also use, in which case youd rather set the user variables, rather than the system variables

Java is not recognized as an internal or external command

It sounds like you havent added the right directory to your path.

First find out which directory youve installed Java in. For example, on my box its in C:Program Filesjavajdk1.7.0_111. Once youve found it, try running it directly. For example:

c:> c:Program Filesjavajdk1.7.0_11binjava -version

Once youve definitely got the right version, add the bin directory to your PATH environment variable.

Note that you dont need a JAVA_HOME environment variable, and havent for some time. Some tools may use it – and if youre using one of those, then sure, set it – but if youre just using (say) Eclipse and the command-line java/javac tools, youre fine without it.


1 Yes, this has reminded me that I need to update…

Leave a Reply

Your email address will not be published.