Java keytool 错误 bash:keytool:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16333635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
keytool error bash: keytool: command not found
提问by user217929
I have tried to execute keytool from Java bin directory but I get an error with warning bash: keytool: command not found.
我试图从 Java bin 目录执行 keytool,但出现警告 bash: keytool: command not found 的错误。
root@xxxxxx]# keytool -genkey -alias mypassword -keyalg RSA
bash: keytools: command not found
采纳答案by user217929
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]
搜索我的java安装路径
find / -name jre
移动到 java 目录(我的服务器上安装了 jre)
cd /path/to/jre/bin
使用 keytool 命令创建 SSL 证书
./keytool -genkey -alias [mypassword] -keyalg [RSA]
回答by Michael
Use
用
./keytool -genkey -alias mypassword -keyalg RSA
回答by learner_19
Ensure jre is installed.
确保已安装 jre。
cd /path/to/jre/bin/folder
As keytool file is present in the bin folder of jre, give path till bin as in the command above.
由于 jre 的 bin 文件夹中存在 keytool 文件,因此在上面的命令中给出直到 bin 的路径。
Then you can do:
然后你可以这样做:
keytool -genkey -alias aliaskeyname -keyalg RSA -keystore C:\mykeystore
The additional option -keystore will help you to specify the path where you want the generated self signed certificate.
附加选项 -keystore 将帮助您指定生成自签名证书的路径。
回答by Hpsaturn
You tried:
你试过:
sudo apt-get install oracle-java6-installer --reinstall
and:
和:
sudo update-alternatives --config keytool
回答by AldaronLau
It seems that calling sudo update-alternatives --config java
effects keytool. Depending on which version of Java is chosen it changes whether or not keytool is on the path. I had to chose the open JDK instead of Oracle's JDK to not get bash: /usr/bin/keytool: No such file or directory
.
似乎调用sudo update-alternatives --config java
效果keytool。根据选择的 Java 版本,它会更改 keytool 是否在路径上。我不得不选择开放的 JDK 而不是 Oracle 的 JDK 才能获得bash: /usr/bin/keytool: No such file or directory
.
回答by shyam k
Please follow the steps:
请按照以下步骤操作:
first set the domain using
setDomain.sh
command go todomain/bin
location and execute./setDomain.sh
commandgo to
java/bin
folder and executekeytool
command.
首先使用
setDomain.sh
命令设置域转到domain/bin
位置并执行./setDomain.sh
命令转到
java/bin
文件夹并执行keytool
命令。
keytool -genkey -keyalg RSA -kaysize 2048 -alias name -kaystore file.jks
keytool -genkey -keyalg RSA -kaysize 2048 -alias name -kaystore file.jks
回答by MSR SHAHEEN
find your jre location ::sudo find / -name jre
And then :: sudo update-alternatives --install /usr/bin/keytool keytool /opt/jdk/<jdk.verson>/jre/bin/keytool 100
找到您的 jre 位置 ::sudo find / -name jre
然后 ::sudo update-alternatives --install /usr/bin/keytool keytool /opt/jdk/<jdk.verson>/jre/bin/keytool 100
回答by P.R.
If you are looking for keytool
because you are working with Android studio / Google Firebase, there is a keytool bundled with Android Studio. After extracting the zip file, the path to keytool is android-studio/jre/bin
.
如果您正在寻找是keytool
因为您正在使用 Android Studio / Google Firebase,那么 Android Studio 捆绑了一个 keytool。解压zip文件后,keytool的路径为android-studio/jre/bin
.
回答by Gene
Keytool comes with your Java library. So you have to execute the Keytool command from your?/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/bin directory. Or you can add JAVA_HOME to your environmental variables (Windows) or ~/.bash_profile (Linux)
Keytool 随您的 Java 库一起提供。因此,您必须从?/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home/jre/bin 目录中执行 Keytool 命令。或者您可以将 JAVA_HOME 添加到您的环境变量 (Windows) 或 ~/.bash_profile (Linux)
回答by Robert Silver
You could also put this on one line like so:
你也可以像这样把它放在一行上:
/path/to/jre/bin/keytool -genkey -alias [mypassword] -keyalg [RSA]
/path/to/jre/bin/keytool -genkey -alias [mypassword] -keyalg [RSA]
Wanted to include this as a comment on piet.t answer but I don't have enough rep to comment.
想将此作为对 piet.t 答案的评论,但我没有足够的代表发表评论。
See the "signing" section of this article that describes how to access the keytool.exe without changing your working directory to the path: https://flutter.dev/docs/deployment/android#signing-the-app
请参阅本文的“签名”部分,其中描述了如何在不将工作目录更改为路径的情况下访问 keytool.exe:https: //flutter.dev/docs/deployment/android#signing-the-app
Note that they say you can type in space separated folder names like /"Program Files"/ with quotes but I found in bash i had to separate with back slashes like /Program\ Files/.
请注意,他们说您可以输入空格分隔的文件夹名称,例如 /"Program Files"/ 带引号,但我发现在 bash 中我必须用反斜杠分隔,例如 /Program\ Files/。