我正在尝试设置JDK安全证书。我从浏览器复制了证书c:\ cer.cer。我还尝试这个
set JAVA_HOME="C:\Program Files (x86)\Java\jdk1.8.0_141"
"%JAVA_HOME%\bin\keytool" -import -alias nexussrv -keystore "%JAVA_HOME%\jre\lib\security\cacerts" -file c:\cer.cer
我收到错误
Set-Variable : A parameter cannot be found that matches parameter name 'import'.
At line:1 char:84
+ ... es (x86)\Java\jdk1.8.0_141" "%JAVA_HOME%\bin\keytool" -import -alias
...
+ ~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Variable], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.SetVariableCommand
或
At line:1 char:28
+ "%JAVA_HOME%\bin\keytool" -import -alias nexussrv -keystore "%JAVA_H ...
+ ~~~~~~~
Unexpected token '-import' in expression or statement.
At line:1 char:36
+ "%JAVA_HOME%\bin\keytool" -import -alias nexussrv -keystore "%JAVA_H ...
+ ~~~~~~
Unexpected token '-alias' in expression or statement.
+ CategoryInfo : ParserError: (:) [],
ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
我做错了什么?
答案 0 :(得分:0)
我刚检查了我的脚本,他们使用' -importcert'参数,而不是'导入' ...正如此Java 8工具链链接中所述:" https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html"
答案 1 :(得分:0)
在执行命令之前,检查命令提示符中是否正确设置了%JAVA_HOME%。如果java home path错误意味着它不会识别-import和-alias参数。