How can I find and run the keytool

438,649

Solution 1

I found a solution by myself as below quote. It works fine.

"C:\Program Files\Java\jdk1.6.0_26\bin\keytool.exe" -exportcert -alias
> sociallisting -keystore "D:\keystore\SocialListing"  |
> "C:\cygwin\bin\openssl.exe" sha1 -binary | "C:\cygwin\bin\openssl.exe"
> base64

Solution 2

Simply enter these into Windows command prompt.

cd C:\Program Files\Java\jdk1.7.0_09\bin

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\userName\.android\debug.keystore" -list -v

The base password is android

You will be presented with the MD5, SHA1, and SHA256 keys; Choose the one you need.

Solution 3

To get android key hash code follow these steps (for facebook apps)

  1. Download the openssl for windows here
  2. now unzip to c drive
  3. open cmd prompt
  4. type cd C:\Program Files\Java\jdk1.6.0_26\bin
  5. then type only keytool -export -alias myAlias -keystore C:\Users\<your user name>\.android\myKeyStore | C:\openssl-0.9.8k_WIN32\bin\openssl sha1 -binary | C:\openssl-0.9.8k_WIN32\bin\openssl enc -a -e
  6. Done

To get Certificate fingerprint(MD5) code follow these steps

  1. go to - C:\Program Files\Java\jdk1.6.0_26\bin
  2. inside the bin folder run the jarsigner.exe file
  3. open cmd prompt
  4. type cd C:\Program Files\Java\jdk1.6.0_26\bin
  5. then again type on cmd keytool -list -keystore "C:/Documents and Settings/<your user name>/.android/debug.keystore"
  6. it will ask for Keystore password now. The default is "android" type and enter
  7. Done.

Solution 4

keytool is part of the JDK.

Try to prepend %{JAVA_HOME}\ to the exec statement or c:\{path to jdk}\bin.

Solution 5

I found this on another post, which did not get many upvotes, but it was super helpful for me. So will add it here.

Android Studio will bring a keytool with it.

C:\Program Files\Android\Android Studio\jre\bin

You can see his post below by Richar Heap, with a helpful reference. I did see this before but forgot about it. https://stackoverflow.com/a/51524526/4446406

Share:
438,649

Related videos on Youtube

Nguyen  Minh Binh
Author by

Nguyen Minh Binh

I have been developing many mobile applications for more than 8 years with love, passion and enthusiasm for each and all of my apps. Being a developer, to me, is not only a career, it is also an opportunity to challenge myself and acquire more knowledge with each new project. I recognize myself as a friendly, skilled and disciplined developer, and I can adapt well both individually and collaboratively. Outside of work, I love playing around with my two sons as seeing their innocent smiles gives me more energy and motivation to work harder.

Updated on October 24, 2021

Comments

  • Nguyen  Minh Binh
    Nguyen Minh Binh over 2 years

    I am reading an development guide of Facebook Developers at here

    It says that I must use keytool to export the signature for my app such as:

    keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
    

    I do not know how to find the keytool in order to run it. I tried to open a Windows command prompt and paste the above command, but it did not work.

    • Elshan
      Elshan about 5 years
      if you are running Linux based system /usr/local/java/bin# ./keytool if you are running Windows find the JDK install path and check bin folder
    • ashraf alqaabera
      ashraf alqaabera about 4 years
      i found this ansour you can use it to solve the prob stackoverflow.com/a/57390582/13405428
  • Nguyen  Minh Binh
    Nguyen Minh Binh about 13 years
    Could you tell me how to run below command? keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
  • Nguyen  Minh Binh
    Nguyen Minh Binh about 13 years
    Yes, I did. and when I run above command, the CMD say: 'openssl' is not recognized as an internal or external command, operable program or batch file.
  • Matthew Willis
    Matthew Willis about 13 years
    You probably need to install the openssl package as well via cygwin's setup.
  • Nguyen  Minh Binh
    Nguyen Minh Binh about 13 years
    I installed openssl package already. The problem still occurs :(
  • Matthew Willis
    Matthew Willis about 13 years
    Can you run openssl by itself? What options do you see when you type "open" and press tab?
  • Nguyen  Minh Binh
    Nguyen Minh Binh about 13 years
    I installed cygwin as well as openssl already. But I don't know how to run them. I just run windows command line (cmd) and type the command.
  • Matthew Willis
    Matthew Willis about 13 years
    You have to access the cygwin shell. Installing cygwin should've made a shortcut on your desktop for it.
  • ArtOfWarfare
    ArtOfWarfare over 11 years
    This worked for me up until the final step. After typing in "android" it spits out garbage... my guess is it isn't using the proper encoding? If I enter in something like "blah", it tells me the password was incorrect. So it knows I have the password correct when I type in "android"
  • ArtOfWarfare
    ArtOfWarfare over 11 years
    I found the issue was I had left off the flags -list and -v
  • Broo
    Broo over 10 years
    this worked for me. For debug keys use the -alias androiddebugkey.
  • Jaime Montoya
    Jaime Montoya about 7 years
    I found it here: C:\Program Files\Java\jre1.8.0_111\bin\keytool.exe
  • Andrew Grow
    Andrew Grow almost 6 years
    I use for the release version next line: 1) cd C:\Program Files\Java\jdk1.8.0_162\bin and next 2) keytool -list -v -keystore "C:\AndroidProjects\Project1\app\myapp.keystore"
  • SHAHM
    SHAHM almost 6 years
    Or C:\Program Files\Android\Android Studio\jre\bin
  • Todd Hale
    Todd Hale about 5 years
    I put the cer file and truststore file in the same directory and used this command: "%JAVA_HOME%\bin\keytool" -import -keystore truststore -file certificate.cer -alias my-alias
  • Pete Alvin
    Pete Alvin over 4 years
    Thanks @SHAHM: great for us folks that don't want to explicitly download Java AGAIN and be bugged every week to upgrade to latest version.
  • Gustaf Liljegren
    Gustaf Liljegren over 4 years
    keytool error: java.lang.Exception: Only one command is allowed: both -exportcert and -list were specified.
  • dantechguy
    dantechguy about 3 years
    I found that only keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore worked for me. Found here from Google :)
  • Gwi7d31
    Gwi7d31 almost 3 years
    For the "found it here" @JaimeMontoya comment as an addition. Add the directory for keytool.exe to your PATH. It'll make your life a whole lot easier.