How can I find and run the keytool
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
keytool is a command-line utility bundled with the Java Development Kit (JDK) for managing cryptographic keys and certificates. It is located in the bin/ directory of your JDK installation. If keytool is not found when you type it in a terminal, either the JDK is not installed, or the bin/ directory is not on your system PATH. Finding and running keytool requires knowing where the JDK is installed on your operating system.
Finding keytool on Your System
Windows
macOS
Linux
Adding keytool to PATH
If keytool is not found, add the JDK bin/ directory to your PATH:
Windows
macOS / Linux
Common keytool Commands
Generate a Key Pair
This creates a new RSA key pair and self-signed certificate stored in mykeystore.jks.
List Keystore Contents
Export a Certificate
Import a Certificate
Import into Java's Trusted Certificates (cacerts)
The default password for Java's cacerts keystore is changeit.
Delete an Entry
Generate a CSR (Certificate Signing Request)
Android Development
For Android development, keytool is used to view the debug keystore's SHA-1 fingerprint, required for Google APIs:
The debug keystore is automatically created by Android Studio at ~/.android/debug.keystore with the password android.
Common Pitfalls
- "keytool is not recognized" / "command not found": The JDK
bin/directory is not on yourPATH. Either add it toPATHor use the full path tokeytool(e.g.,/usr/lib/jvm/java-21/bin/keytool). - JRE installed instead of JDK: The JRE (Java Runtime Environment) may not include
keytoolin some distributions. Install the full JDK to guaranteekeytoolis available. - Wrong keytool version: If multiple JDK versions are installed,
which keytoolmay point to an older version. Usekeytool -versionor the full path to ensure you are running the intended version. - Forgetting the keystore password: There is no built-in way to recover a lost keystore password. The default password for Java's
cacertsischangeit, but custom keystores use whatever password was set at creation. - Permission denied on cacerts: Modifying the system
cacertsfile requires administrator or sudo privileges. On Windows, run the command prompt as Administrator. On Linux/macOS, prefix withsudo.
Summary
keytoolis in thebin/directory of your JDK installation (not the JRE)- Find it with
which keytool(macOS/Linux),where keytool(Windows), or check$JAVA_HOME/bin/ - Add the JDK
bin/directory to your systemPATHifkeytoolis not found - Common operations include generating key pairs, listing keystore contents, and importing/exporting certificates
- For Android development, use
keytoolto extract SHA-1 fingerprints from the debug keystore

