I
Insight Horizon Media

What is Java Keytool

Author

Robert Miller

Published Apr 08, 2026

keytool is a key and certificate management utility. It allows users to administer their own public/private key pairs and associated certificates for use in self-authentication (where the user authenticates himself/herself to other users/services) or data integrity and authentication services, using digital signatures.

How do I use Keytool?

  1. Generate the server certificate. Type the keytool command all on one line: …
  2. Export the generated server certificate in keystore. jks into the file server. …
  3. To add the server certificate to the truststore file, cacerts. …
  4. Type yes , then press the Enter or Return key.

What is Java keystore used for?

A Java Keystore is a container for authorization certificates or public key certificates, and is often used by Java-based applications for encryption, authentication, and serving over HTTPS. Its entries are protected by a keystore password.

Is Keytool part of Java?

keytool is part of the standard java distribution. It is used for managing keys and certificates you can sign things with, in your case, probably a jar file.

What is in Keytool command?

The keytool command stores the keys and certificates in a keystore . The keytool command uses the jdk. certpath. disabledAlgorithms and jdk.

What is Java Cacerts?

cacerts is where Java stores public certificates of root CAs. Java uses cacerts to authenticate the servers. Keystore is where Java stores the private keys of the clients so that it can share it to the server when the server requests client authentication.

How do I download Java Keytool?

  1. Download and install a recent version of the JRE from Oracle.
  2. Locate the keytool with two commands. …
  3. Add the directory where keytool.exe resides to the PATH variable. …
  4. Return to a directory that belongs to your user name: …
  5. Repeat steps 2 and 3 for any terminal window in which you want to use the keytool command.

How do I use Keytool on Mac?

To answer the original question, on my Mac, keytool is found at /Library/Java/JavaVirtualMachines/jdk1. 7.0_45. jdk/Contents/Home/bin/keytool . You can locate the Java home directory using the /usr/libexec/java_home command line tool on Mac OS X 10.5 or later.

Do we need to install Keytool?

In order to run keytool from the command line, you need to add it to your system PATH. This step is required on Windows only, as keytool will is automatically installed on /usr/bin on macOS/Linux.

How do I use Windows Keytool?
  1. (For Microsoft Windows) Type keytool.exe and press Enter.
  2. (For UNIX) Type keytool and press Enter. You can use the keytool utility from Oracle JDK Java 1.5 or 1.6.
Article first time published on

Is Java keystore secure?

Java KeyStores are used to store key material and associated certificates in an encrypted and integrity protected fashion. Like all things Java, this mechanism is pluggable and so there exist a variety of different options.

Where is the Java Keystore on Windows?

On a Windows system, the location of the Java cacerts keystore is: install_dir \jre\lib\security\, and the location of the keytool is install_dir \jre\bin\.

What is Java security keystore?

The Java KeyStore is a database that can contain keys. A Java KeyStore is represented by the KeyStore ( java. security. … A KeyStore can be written to disk and read again. The KeyStore as a whole can be protected with a password, and each key entry in the KeyStore can be protected with its own password.

What is Java keystore password?

Any Java developer knows that the default password for Java keystores is “changeit”. If you want to use the keystore files bundle with Java (which we do not recommend), please change it to a strong password.

How do I use Keytool in Linux?

  1. Download and install a recent version of the JRE from Oracle.
  2. Locate the keytool with two commands. …
  3. Add the directory where keytool.exe resides to the PATH variable. …
  4. Return to a directory that belongs to your user name:

Where is Keytool in Linux?

The default JDK keystore on Oracle Linux is the file /etc/pki/java/cacerts . You can use the keytool command to generate self-signed certificates and to install and manage certificates in the keystore.

How do I know if Java is installed?

  1. In the Search bar, type Control Panel.
  2. Click Programs.
  3. If the Java icon present, then Java is installed.
  4. If not, click Programs and Features, and look for installed versions of Java in the J’s.

How do you add a certificate to a Java program?

  1. Open a command prompt and change to the following directory: location \bin\jre\7.0\bin. …
  2. Run the following command line. …
  3. Enter yes when prompted to trust or add the certificate.

How do I set Java path in Windows 10?

  1. Select the Advanced tab and then click environment variables.
  2. In the system, variables click the New button. …
  3. Now in the system variables go to the path and click the edit button.
  4. Click the New button.
  5. Now add the following path: %JAVA_HOME%\bin.

Where does Java Look for certificates?

A certificates file named cacerts resides in the security properties directory, java. home \lib\security, where java. home is the runtime environment directory (the jre directory in the SDK or the top-level directory of the Java™ 2 Runtime Environment).

Do I need to restart Java after updating keystore?

JVM needs restart after importing certs to the keystore. Check to see whether there is a key with the same CN information but a different alias.

What is cacerts file used for?

The cacerts file is a collection of trusted certificate authority (CA) certificates. Oracle includes a cacerts file with its SSL support in the Java™ Secure Socket Extension (JSSE) tool kit and JDK. It contains certificate references for well-known Certificate authorities, such as VeriSign™.

How do I know if Keytool is installed Linux?

  1. to find where jre is installed, use this. sudo find / -name jre.
  2. Then look for keytool in path_to_jre or in path_to_jre/bin.
  3. cd to keytool location.
  4. then run ./keytool.
  5. Make sure to add the the path to $PATH by. …
  6. To make sure you got it right after this, run. …
  7. for future edit you bash or zshrc file and source it.

How do I read a Keytool certificate?

  1. Check a stand-alone certificate keytool -printcert -v -file mydomain.crt.
  2. Check which certificates are in a Java keystore keytool -list -v -keystore keystore.jks.
  3. Check a particular keystore entry using an alias keytool -list -v -keystore keystore.jks -alias mydomain.

How do I import a certificate using Keytool?

  1. Go to your java_home\jre\lib\security.
  2. (Windows) Open admin command line there using cmd and CTRL + SHIFT + ENTER.
  3. Run keytool to import certificate: (Replace yourAliasName and path\to\certificate. cer respectively)

What is Keytool Mac?

keytool is a standard program that ships with the Java Development Kit (JDK) or runtime (JRE). Both Oracle’s JDK and OpenJDK ship with it, and on MacOS and Linux it’s usually simple enough to just install the JDK and call it a day.

Where does Java Keytool store keys?

By default, Java has a keystore file located at JAVA_HOME/jre/lib/security/cacerts. We can access this keystore using the default keystore password changeit.

Where does the Keytool command run?

keytool is located in JDK bin directory ($JAVA_HOME/bin). JAVA_HOME is your JDK installation directory. To use that command line you should also include $JAVA_HOME/bin to your PATH environment variable. Keytool command can be run at your dos command prompt, if JRE has been set in your classpath variable.

How do I install a Windows keystore?

  1. On the Windows Server, right-click the Command Prompt and select the option “Run as Administrator” or you will not be able to create the new keystore file.
  2. Change to the C:\Program Files\Attachmate\ReflectionServer\jre\bin folder.
  3. Run the keytool.exe utility with the options as shown:

What is the difference between keystore and TrustStore Java?

TrustStore is used to store certificates from Certified Authorities (CA) that verify the certificate presented by the server in an SSL connection. While Keystore is used to store private key and identity certificates that a specific program should present to both parties (server or client) for verification.

Is keystore safe?

The Android Keystore is a system that lets developers create and store cryptographic keys in a container making them more difficult to extract from the device. … It was introduced in API 18 (Android 4.3). A strongbox backed Android Keystore is currently the most secure and recommended type of keystore.