228

When I use the command:

C:\>keytool -list -alias androiddebugkey 
            -keystore .android\debug.keystore 
            -storepass android -keypass android

I get this error:

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

I'm not able to get the certificate fingerprint(MD5) on my computer.

I have ensured that the keystore file is present in the appropriate location.

Any help?

2
  • For Flutter: I have written an answer on a different SO post here
    – MendelG
    Commented May 14, 2021 at 21:14
  • The answers here are dominantly for Windows, but troubleshooting your PATH is a common FAQ; it's not hard to find answers for Linux etc once you understand what the problem is. Basically, if you have not installed keytool, install it; then, if the directory where it is installed is not on your PATH, add it there.
    – tripleee
    Commented May 12, 2022 at 6:49

35 Answers 35

283

Check that the directory the keytool executable is in is on your %PATH% environment variable.

For example, on my Windows 7 machine, it is in C:\Program Files (x86)\Java\jre6\bin, and my %PATH% variable looks like C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Java\jre6\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\ (and many other entries)

10
  • i entered this C:\Program Files\Java\jdk1.6.0_21\bin>keytool -list -alias androiddebugkey -keystore .android\debug.keystore -storepass android -keypass android. the error i got is keytool error: java.lang.Exception: Keystore file does not exist: .android\debug .keystore
    – Shalini
    Commented Jun 2, 2011 at 8:46
  • If you do that, it's going to be looking for the keystore in C:\Program Files\Java\jdk1.6.0_21\bin\.android\debug.keystore which is almost certainly not the correct path. You need to give it the correct full path to your keystore. Commented Jun 2, 2011 at 8:53
  • 1
    the keystore file is here C:\Documents and Settings\Shalini\.android> so when i enter C:\Documents and Settings\Shalini\.android>keytool -list -alias androiddebugkey -keystore .android\debug.keystore -storepass android -keypass android . i get this same error 'keytool' is not recognized as an internal or external command, operable program or batch file.
    – Shalini
    Commented Jun 2, 2011 at 9:00
  • 20
    Try C:\Program Files\Java\jdk1.6.0_21\bin\keytool -list -alias androiddebugkey -keystore C:\Documents and Settings\Shalini\.android\debug.keystore -storepass android -keypass android Commented Jun 2, 2011 at 9:06
  • 1
    ok i entered this C:\Documents and Settings\Shalini\.android> C:\Program Files\Java\jdk1.6.0_21 \bin\keytool -list -alias androiddebugkey -keystore C:\Documents and Settings\Shalini\.android\debug.keystore -storepass android -keypass android . the error is The filename, directory name, or volume label syntax is incorrect.
    – Shalini
    Commented Jun 2, 2011 at 9:15
147

This worked for me !! :

Go to this path or where ever you have your keytool.exe file

C:\Program Files\Java\jre7\bin

Hold shift and right click -> then press Open command window here

terminal will pop up, paste this in:

keytool -list -v -keystore "C:\Users\"Your-User-Name(no quotes)"\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

gives you both MD5 and SHA1

3
  • This works but @Amt87 's answer will make sure you have keytool available in any directory without having to first cd to the directory where keytool is located (windows only). in OS X (Mac), edit your .profile and be sure to include :$PATH at the end or you will have no commands. (see architectryan.com/2012/10/02/…) Commented Sep 4, 2014 at 4:57
  • For me: C:\Program Files\Java\jdk1.8.0_281\jre\bin
    – Nazmul81
    Commented Feb 10, 2021 at 6:38
  • As an addition to whoever else having my problem, I use IntelliJ's own JDK that comes with the IDE. Running the command inside the proper directory and it having keytool.exe in it still returned that keytool was not found on CMD or PowerShell. But it worked when run from the IDE's terminal. Commented Mar 23, 2021 at 13:27
88

Found it.

GO TO:

my computer->rightClick->properties->Advanced system settings->environment variables->find path in system variables->dbl click-> paste the "C:\Program Files\Java\jdk1.6.0_16\bin"->OK

GO TO:

cmd -> keytool -list -alias androiddebugkey -keystore "C:\Users\meee\.android\debug.keystore" -storepass android -keypass android
0
34
  1. Go to My computer -> right click -> system properties -> environmental variables -> Path -> add you jdk/bin to this path

    C:\Program Files\Java\jdk1.8.0_211\bin
    

*if this not work then

  1. In cmd set the path by using the below command

    set PATH=C:\Program Files\Java\jdk1.8.0_211\bin
    

now the path is set now you can use the keytool

2
  • Thanks, in Windows 10 I tried the first solution and for some reasons didn't work. The 2nd one works great. Commented Jan 19, 2020 at 9:19
  • Thanks. The second option worked for me on Windows 10 x64
    – mdhz
    Commented Jun 17, 2020 at 8:41
19

keytool ships with Android Studio as part of the JRE needed to run Android Studio.

On Windows its: C:\Program Files\Android\Android Studio\jre\bin\keytool.exe

On Mac its: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool

Add it to your environment variables then run the keytool command again.

2
  • Thanks a lot!!! As for 2022, totally works!
    – aetrnm
    Commented Jan 15, 2022 at 21:08
  • In my case, I added the "C:\Program Files\Android\Android Studio\jre\bin\keytool.exe"as a path variable. And tried out. But it didn't work quite as expected inspite the restart I did. Though "cd"ing via cmd to C:\Program Files\Android\Android Studio\jre\bin\ and ensure the file keytool.exe exists. I was able to work the following cmd "keytool -genkey -v -keystore %userprofile%\upload-keystore.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias upload" as mentioned in docs.flutter.dev/deployment/android#create-an-upload-keystore Commented Oct 9, 2023 at 12:33
14

So if you have the following structure now:

 C:\Program Files\Java\jre6\bin\
                                keytool.exe
                                debug.keystore

then execute:

C:\Program Files\Java\jre6\bin>keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android 
2
  • I have jdk-13 ..it has no jre file .How can I solve this Commented Nov 11, 2019 at 9:27
  • Navigate to C:\Softwares\jdk1.8.0_261\jre\bin folder. Commented Sep 29, 2020 at 12:15
12

This is due to path for keytool.exe not set.

Open command prompt in your windows machine, go to where you would like to run keytool cmd and then set path where keytool.exe present

Step 1 : Open cmd promt and run

cd C:\Program Files\Java\jdk<your jdk version>\jre\lib\security

Step 2 : Run below cmd to set path using

set PATH=C:\Program Files\Java\jdk<your jdk version>\bin

Step 3 : Run keytool cmd, now it will be able to recognize

keytool -list -alias <rest of the arguments>
11

On windows 8, go to C:\Program Files\Java\jre7\bin and in the address bar, type "cmd" without the quotes. This will launch the terminal. Then type in string as describe here.

7

if you want to run keytool from any location of terminal

example: C:>keytool

you need to add the system variables

for Windows:

1) create:
JAVA_HOME
C:\Program Files\Java\jdk1.7.0_45

2) add to Path
%JAVA_HOME%\bin;
7

all you can do is to navigate to your jre destination in your computer via command line and then once you reach bin, you type the keytool command and it would work.

C:\Program Files (x86)\Java\jre7\bin>
C:\Program Files (x86)\Java\jre7\bin>keytool -list -v -keystore"%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android



Alias name: androiddebugkey
Creation date: 23 Feb, 2014
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 479d4fe7
Valid from: Sun Feb 23 06:19:02 IST 2014 until: Tue Feb 16 06:19:02 IST 2044
Certificate fingerprints:
MD5:  DB:6A:8E:48:22:5B:37:73:B1:91:EF:43:3F:26:F0:EC
SHA1: B4:6B:2E:5F:5A:30:C5:E4:E7:12:BB:F0:74:FC:2B:43:64:3A:FC:15
SHA256: CB:59:F3:20:7D:5B:87:99:6C:0D:32:79:79:CF:4E:8C:16:C2:37:81:7B:
B0:AF:D2:EC:3C:11:21:53:58:62:F6
Signature algorithm name: SHA256withRSA
Version: 3
Extensions:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: FA 96 17 9E 94 73 C3 42   F0 4B 55 5B C7 5B EE BB  .....s.B.KU[.[..
0010: C3 E5 D3 61                                        ...a
]
]
1
  • 1
    Which one of these is key hash and which one is Development Key Hashes and which one is Release Key Hashes?
    – TPWang
    Commented Aug 23, 2015 at 5:36
7

Easy, just find the location where keytool executable is, normally is in java/jre(Version)/bin forexample in my computer is in C:\Program Files\Java\jre7\bin. all you have to do is go to environment variables, click PATH to make it active, then click edit, then add complete path where your keytool is, for me i will add C:\Program Files\Java\jre7\bin this will allow you to execute keytool commands without going to the directory where keytool is installed.

6

I suffered alot trying to find a solution to it and finally I found the solution by first setting the jre path to system variables by navigating to::

control panel > System and Security > System > Advanced system settings 

Under System variables click on new

Variable name: KEY_PATH
Variable value: C:\Program Files (x86)\Java\jre1.8.0_171\bin

Where Variable value should be the path to your JDK's bin folder.

Then open command prompt and Change directory to the same JDK's bin folder like this

C:\Program Files (x86)\Java\jre1.8.0_171\bin 

then copy and paste the code below in cmd

keytool -list -v -keystore "C:\Users\user\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android   
5

Make sure JAVA_HOME is set and the path in environment variables reflects the bin directory of JAVA_HOME. Basically, the PATH should be able to find the keytools.exe file in your jdk location.

3

This means, that your shell couldn't find the tool on your harddisk.

A)

  • Change the working directory to C:\Program Files\Java\jre6\bin\
  • Execute keytool -list -alias androiddebugkey keystore <full directory name make sure that you use enclosing in quotes> -storepass android -keypass android

B)

  • Add C:\Program Files\Java\jre6\bin\ to your PATH variable
2

In my case problem was in using PowerShell instead of CMD :)

0
2

i am using gui tool ,Must try Who don't want to use keystore command line

it is GUI tool for create keystore.jks and export pem file and lot

https://keystore-explorer.org/downloads.html

2

If you use flutter and have downloaded openssl-for-windows:

  • Open Command Prompt
  • Type flutter doctor -v
  • Under Android toolchain you will see Java binary at: C:\Program Files\Android\jre\bin\java
  • Now copy the line of code and do cd C:\Program Files\Android\jre\bin
  • Type keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Username\.android\debug.keystore" | "Location to openssl.exe" sha1 -binary | "Location to openssl.exe" base64

(Double quotes are necessary)

  • Enter keystore password: android (default password)

This will give you Key Hash.

Now,

if you are trying to get your SHA fingerprint, this is the easiest way to get it -->

Step 1: Open terminal in your project directory

Step 2: cd android

Step 3: Run ".\gradlew signingReport"

Done!

1

Give:

keytool -list -keystore ~/.android/debug.keystore

Also in your line there is a space in keystore. Please check it.

0
1

I know there are already several answers but none of them worked for me, so i am posting one that worked for me, may be helpful for someone.

First of all directory to keytool.exe must be on path

and if instead of directory being on path it is giving error then Try starting command line as a normal user instead of as a administrator or changing the directory to home directory

1

Open "Environment Variables" (you can get to it from your start menu search in Win10) double check the path that the jdk is in, to make sure it exists. For me, it said "...jdk1.8/bin" But when I copied that into Windows Explorer or command prompt, it said that it didn't exist. I checked where it should have been, and it said "jdk1.8.0_77"

A simple rename of the setting in Android Studio and keytool was working!

1

The keytool command might not be in your path—it’s part of Java, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v and locate the path printed after ‘Java binary at:’. Then use that fully qualified path replacing java (at the end) with keytool. If your path includes space-separated names, such as Program Files, use platform-appropriate notation for the names. For example, on Mac/Linux use Program\ Files, and on Windows use "Program Files".

1

A simple solution of error is that you first need to change the folder directory in command prompt. By default in command prompt or in terminal(Inside Android studio in the bottom)tab the path is set to C:\Users#Name of your PC that you selected\AndroidStudioProjects#app name\flutter_app> Change accordingly:- C:\Users#Name of your PC that you selected\AndroidStudioProjects#app name\flutter_app>cd\

type **cd** (#after flutter_app>), type only cd\ not comma's

then type cd Program Files\Java\jre1.8.0_251\bin (#remember to check the file name of jre properly)

now type keytool -list -v -keystore "%USERPROFILE%.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android (without anyspace type the command).

screenshot of the codes to run

1
  • I am a beginner flutter developer struggling to finish up my app. I kept getting this error, not until i saw this answer. Thank you.
    – Simeon
    Commented Sep 16, 2020 at 11:33
1
  1. Go to C:->Program Files->Java->jdk->bin. Here,keytool.exe file resides. 2.Copy the path till bin. 3.Go to: Control Panel\System and Security\System 4.Click Advanced System Setting 5.Click Environment Variables 6.Under System Variables(bottom half): Double click on Variable: Path B. Add the path: (Click New then add) C:\Program Files\Java\jdk1.8.0_191\bin (your path) 8.VERIFY: Open command prompt & enter "Keytool" It should show keytool details & no error mssg.
1

add C:\Program Files\Java\jdk-15.0.1\bin this into Environment Variables. refer to this website.

1

That simply means the keytool keyword is not installed in your system visit : visit here and download java JDK first.

Then set the java JDK in your environmental variable.

0

The Works for fine

Go to Path

C:\Program Files\Java\jre7\bin> keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Developer\.android\debug.keystore"

Then enter Ketsore Password and job done!!

0

Open Command prompt type this..

"c:\Program Files(x86)\Java\jdk1.7.0\bin\keytool.exe" -list -v -alias androiddebugkey -keystore "C:\Users\EIS.android\debug.keystore" -storepass android -keypass android

Then Hit Enter MD5 and SHA1 key will get

0

For windows 10 you need to path C:\Program Files\Java\jre1.8.0_161\bin

restart command and open

0

Locate where your keytool.exe inside java installation folder

mine is C:\Program Files\Java\jre1.8.0_181\bin open cmd anywhere and run

SET PATH=%PATH%;C:\Program Files\Java\jre1.8.0_181\bin;

change the path to the path you located your keytool.exe

0

My case is, it doesn't work wherever I call it, no matter I path the file or not, if I open it with powershell.

but it works if I open it with cmd.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.