您可以通过使用capgen.bat 工具的-config params.json 属性来做到这一点。
但是,您必须下载和使用至少3.1.0 版本的capgen.bat 文件,因为即使3.0.5 没有提到的属性(见下文)。这可以通过下载3.1.0 version of JavaCard Development Kit Tools即java_card_tools-win-bin-b_17-06_jul_2021.zip文件来实现。
证明(3.0.5 版本)
PS C:\Users\pc> capgen.bat -version
CapGen [v3.0.5]
Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
PS C:\Users\pc> capgen.bat -help
usage: capgen [-options] filename
where options include:
-help Print this message and exit.
-nobanner Do not display informational messages.
-o <filename> Output filename. default: a.jar
-version Print version number and exit.
证明(3.1.0 版本)
PS C:\Users\pc> C:\development\code\java_card_tools-win-bin-b_17-06_jul_2021\bin\capgen.bat -version
CapGen [v3.1.0]
Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
PS C:\Users\pc> C:\development\code\java_card_tools-win-bin-b_17-06_jul_2021\bin\capgen.bat -help
usage: capgen [-options] filename
where options include:
-help Print this message and exit.
-nobanner Do not display informational messages.
-o <filename> Output filename. default: a.jar
-version Print version number and exit.
-config Run capgen in extended mode. In this case the filename must have .json extension.
现在,这是我设置json 文件的方法:
{
"inputConfig": {
"CAP_AID": "01:02:03:04:05:10",
"CAP_name": "helloworld",
"CAP_version": "1.0",
"outputDir": "output",
"debug": true,
"inputPackages": [{
"jcainputfile": "helloworld.jca"
}]
}
}
这是我调用命令的方式:
C:\development\code\java_card_tools-win-bin-b_17-06_jul_2021\bin\capgen.bat -config .\jca-to-cap.json
helloworld.cap 文件出现在.\output\helloworld\javacard 目录中。您可以使用 json 文件中的outputDir 选项来更改目标文件夹。
注意:通过这种方式获得的 cap 文件比使用 convert_applet.bat 文件的“正常”方式更轻。