首页 > 解决方案 > Java Card JCA 文件到 CAP 文件名

问题描述

使用将 hello.jca 文件转换为 hello.cap 文件

./capgen.bat ".\hello.jca" -o ".\hello.cap"

即使我指定了输出文件名,输出文件也始终是 a.jar。

标签: javaappletsmartcardjavacardapdu

解决方案


有一种方法可以通过使用工具的-config params.json属性来做到这一点capgen.bat

但是,您必须下载和使用capgen.bat至少3.1.0版本的文件,因为甚至3.0.5没有提到的属性(见下文)。这可以通过下载3.1.0 版本的 JavaCard Development Kit Toolsjava_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目录中。您可以使用jsonoutputDir文件中的选项来更改目标文件夹。

注意:通过这种方式获得的cap文件的重量比使用convert_applet.bat文件的“正常”方式要轻。


推荐阅读