Create a Java Keystore

A Java KeyStore (JKS) is a repository of security certificates. It is required when building mobile apps for Android and for web security encryption.

To create a keystore, you need a third-party tool such as keytool, a command line utility included with the Java JDK. Other tools are also available, such as a freeware KeyTool GUI. The Android Studio also enables you to create keystores. (It is not required for developing Android apps, but it can be useful for the emulators it provides.)

  • Using keytool, enter the following command, then respond to the prompts:
    keytool -keystore <KeystoreName>.jks -genkey -alias <KeystoreAlias>

    For example:

    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\>keytool -keystore unifacedoc.jks -genkey -alias UnifaceDoc
    Enter keystore password:
    Re-enter new password:
    What is your first and last name?
      [Unknown]: rocketsoftware.com
    What is the name of your organizational unit?
      [Unknown]:  Rocket Uniface Lab
    What is the name of your organization?
      [Unknown]:  Rocket Software
    What is the name of your City or Locality?
      [Unknown]:  Amsterdam
    What is the name of your State or Province?
      [Unknown]:  N-H
    What is the two-letter country code for this unit?
      [Unknown]:  NL
    Is CN=Unknown, OU=Rocket Uniface Lab, O=Rocket Software, L=Amsterdam, ST=N-H, C=NL correct
    ?
      [no]:  y
    
    Enter key password for <client>
            (RETURN if same as keystore password):
    Re-enter new password:
    
    C:\>

    For more information, consult the Oracle Java documentation at http://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html and Creating a KeyStore in JKS Format.

  • If you have Android Studio:
    • Choose BuildGenerate Signed APK.
    • In the resulting dialog, for the Key store path field, choose Create New to open the New Key Store dialog.

      Android Studio New Key Store dialog

    • Enter the desired information and click OK.

Both of these tools create a Java keystore file (in this case, called unifacedoc.jks) which can be used to sign the mobile apps you create for Android.

Related Topics