英文:
Can not open Windows-MY keystore when using jpackage
问题
问题:
在使用JPackage创建Windows可执行文件时,无法使用KeyStore。它返回一个错误。
代码:
KeyStore.getInstance("Windows-MY");
会抛出异常:
java.security.KeyStoreException: 找不到 Windows-MY
at java.base/java.security.KeyStore.getInstance(Unknown Source)
...
Caused by: java.security.NoSuchAlgorithmException: Windows-MY密钥库不可用
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source) at java.base/java.security.Security.getImpl(Unknown Source)
在Windows上运行jpackage并尝试执行KeyStore.getInstance("Windows-MY");
会返回上述错误。
在IDE中运行应用程序而不使用JPackage可以正常工作。
英文:
Problem:
Using JPackage to create an executable for Windows does not work with KeyStore. It returns an error.
Code:
KeyStore.getInstance("Windows-MY");
will throw exception:
java.security.KeyStoreException: Windows-MY not found
at java.base/java.security.KeyStore.getInstance(Unknown Source)
...
Caused by: java.security.NoSuchAlgorithmException: Windows-MY KeyStore not available
at java.base/sun.security.jca.GetInstance.getInstance(Unknown Source) at java.base/java.security.Security.getImpl(Unknown Source)
Running the jpackage for Windows and trying to execute KeyStore.getInstance("Windows-MY");
returns the error above.
Running the application in the IDE without JPackage works fine.
答案1
得分: 5
Windows-MY密钥库的支持是jdk.crypto.mscapi
模块的一部分。我猜这在您当前通过jpackage
进行的设置中并未包含。我对模块的经验有限,但我猜您需要在您的module-info.java
中添加requires jdk.crypto.mscapi;
,或者如您在评论中提到的,通过jpackage
命令行使用--add-modules
添加它(例如,--add-modules jdk.crypto.mscapi
)。
英文:
The support for the Windows-MY keystore is part of the module jdk.crypto.mscapi
. I guess this doesn't get included with your current setup through jpackage
. I don't have much experience with modules, but I guess you need to add requires jdk.crypto.mscapi;
to your module-info.java, or - as you mentioned in the comments - add it to the jpackage
command line with --add-modules
(e.g. --add-modules jdk.crypto.mscapi
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论