'keytool' is not recognized as an internal or external command

Thidasa Pankaja picture Thidasa Pankaja · May 1, 2017 · Viewed 14.4k times · Source

I've created a small Android application using Ionic and I was going to build the signed apk to test the app.

When I typed 'keytool' command in my command prompt I'm getting this error

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

And I tried googling and all solved problems mentions that it's a problem with Path variable of JDK. I tried changing my 'JAVA_HOME' variable value to 'C:\Program Files\Java\jdk1.8.0_131\bin' and to 'C:\Program Files\Java\jre1.8.0_131\bin' and still getting the same error.

But when I run the 'keytool' command it the cmd 'C:\Program Files\Java\jre1.8.0_131\bin' location, it works.

Can anyone help me with this ? What might be a problem that I can't access it globally ?

Answer

Giorgio Antonioli picture Giorgio Antonioli · May 1, 2017

That happens because you haven't added the bin directory of your JAVA_HOME environment variable in your %PATH%.

  1. Add the environment variable JAVA_HOME with path C:\Program Files\Java\jdk1.8.0_131 without the bin directory.
  2. Add the %JAVA_HOME%\bin directory at the end of your %PATH%.