Keytool Error Bash: Keytool: Command Not Found

keytool error bash: keytool: command not found

These are the steps which solved my problem:

  • Search the path where my java was installed

    find / -name jre
  • Move to java directory (where jre was installed on my server)

    cd /path/to/jre/bin
  • Create SSL certificate with keytool command

    ./keytool -genkey -alias [mypassword] -keyalg [RSA]

Keytool command not recognized

The Keytool command can only be ran if you have added it to your path or from within the directory where it is located.

If you are on Windows, most likely it is located here:

C:\Program Files\Java\\bin

You'll need to either run the keytool command from there, or add the keytool location to your PATH environment variable.

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

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)

keytool: command not found

Change directory to C:\Program Files\Java\jdk1.8.0_66\bin and then run your keytool command.

Or

Set the PATH variable permanently (Windows)

  1. Click Start, then Control Panel, then System.

  2. Click Advanced, then Environment Variables.

  3. Add the location of the bin folder of the JDK installation for the
    PATH variable in System Variables. The following is a typical value
    for the PATH variable:

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

i get bash: keytool: command not found. when Obtaining Google Map Key on linux fedora

keytool is part of JRE, search for it in JRE/JDK directory or simply locate keytool

'keytool' is not recognized as an internal or external command

That happens because you haven't added the bin directory of your JAVA_HOME environment variable in your %PATH%.

  1. Add the environment variable JAVA_HOME with path C:\Program Files\Java\jdk1.8.0_131 without the bin directory.
  2. Add the %JAVA_HOME%\bin directory at the end of your %PATH%.

How to fix keytool command error (Linux)?

You need to run the command from within the directory the key tool resides. The key tool is located within the bin directory of the jdk install.

cd ~path_to_jdk/bin
keytool

Note that you will need to specify a number of properties to have the key tool perform the operation you would like.

Here is a list of some of the most common keytool commands.

Keytool is not recognized as an internal or external command

You are getting that error because the keytool executable is under the bin directory, not the lib directory in your example. And you will need to add the location of your keystore as well in the command line. There is a pretty good reference to all of this here - Jrun Help / Import certificates | Certificate stores | ColdFusion

The default truststore is the JRE's cacerts file. This file is typically located in the following places:

  • Server Configuration:

    cf_root/runtime/jre/lib/security/cacerts

  • Multiserver/J2EE on JRun 4 Configuration:

    jrun_root/jre/lib/security/cacerts

  • Sun JDK installation:

    jdk_root/jre/lib/security/cacerts

  • Consult documentation for other J2EE application servers and JVMs


The keytool is part of the Java SDK and can be found in the following places:

  • Server Configuration:

    cf_root/runtime/bin/keytool

  • Multiserver/J2EE on JRun 4 Configuration:

    jrun_root/jre/bin/keytool

  • Sun JDK installation:

    jdk_root/bin/keytool

  • Consult documentation for other J2EE application servers and JVMs

So if you navigate to the directory where the keytool executable is located your command line would look something like this:

keytool -list -v -keystore JAVA_HOME\jre\lib\security\cacert -storepass changeit

You will need to supply pathing information depending on where you run the keytool command from and where your certificate file resides.

Also, be sure you are updating the correct cacerts file that ColdFusion is using. In case you have more than one JRE installed on that server. You can verify the JRE ColdFusion is using from the administrator under the 'System Information'. Look for the Java Home line.

How can I find and run the keytool

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


Related Topics



Leave a reply



Submit