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)
Click Start, then Control Panel, then System.
Click Advanced, then Environment Variables.
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%
.
- Add the environment variable
JAVA_HOME
with path C:\Program Files\Java\jdk1.8.0_131 without the bin directory. - 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
In Java, How to Combine Two Json Arrays of Objects
Passing Data into HTML from Java Via Spring
Spring Boot @Autowired Environment Throws Nullpointerexception
Spring Data JPA Problem With Updating Multiple Entities
Autowiring Httpservletrequest in Spring Controller
Kafka Consumer in Java Not Consuming Messages
Getting Url Parameter in Java and Extract a Specific Text from That Url
Badpaddingexception Decrypting the Encrypted Data in Android
Create List of Object from Another Using Java 8 Streams
Java Nullpointerexception When Adding to Arraylist
How to Convert a Byte to Its Binary String Representation
Subscript and Superscript a String in Android
How to Do Post Request With Raw Data Via Spring Rest Template
Generating Unique Random Numbers Effectively in Java